The translation of this page isn't yet complete. Until it is, unfinished parts use the English original.



所有 Haiku 附带的命令行程序都放置在 /boot/system/bin 目录。您自己的或额外安装的通过 .hpkg 安装的命令行程序将放置在 ~/config/bin 目录。或者您也可以将它们放置在 /boot/system/non-packaged/bin/ 或者 ~/config/non-packaged/bin/。所有这些位置都是 PATH 变量的一部分,并且可以自动被发现。
下面给出的列表并没有包含所有的用于 Haiku 的命令行程序,它只是给出了最常用的几个以方便您的尝试使用。您需要勇敢地去探索 bin/ 文件夹中的命令。以 --help 参数来运行命令行程序,这样会给出该命令的用途和相应的参数选项。

index 关于文件属性的命令: listattr, catattr, addattr, rmattr, copyattr


index 关于文件索引的命令:lsindex, mkindex, reindex, rmindex


index 包管理相关:package, pkgman

The package command is used to manage HPKG packages. Have a look at the article Installing applications to learn the very basics. Usually the tool haikuporter is used to automatically create packages from so-called recipes.

pkgman is used to search, install, update and uninstall packages. Package repositories can be added, dropped and their package lists refreshed. A special kind of update is invoked with the parameter full-sync: it is more aggressive and also downgrades or removes packages, if necessary.
For more details on a parameter, append "--help", e.g. pkgman search --help

index 有用的脚本命令

下面是一些非常有用的命令行工具,尤其适用于撰写脚本(详情请参阅 Bash和脚本)。


alert 该命令将会打开一个带有预定义图标,说明注记和三个按钮的典型警示窗口,并且在终端中返回已选中按钮的标题和退出状态(以0开始)。例如,下面就是一个例子:

alert --idea "FantasticApp(tm) installed successfully! \
Would you like a link to it?" "On Desktop" "In Deskbar" "No thanks"



filepanel 显示一个装载或者保存文件的面板,并且让用户选择相应的文件和位置。同时您将会获取到一个文件或者文件的路径作为返回值。并且还有几个参数可供使用,例如,设置起始目录,窗体的标题,默认保存的文件名。下面是一个例子:

filepanel -s -t "Save your logfile" -d ~/config/settings -n Fantastic.log



hey 是一个小巧的帮助工具,可以发送 BMessages 给应用,并打印出回复结果。它可以用于应用脚本,例如,通过命令行或者脚本 “远程控制” 一个程序。它的使用会有一点复杂。非常感谢 Scot Hacker 的 BeOS 圣经,其中有一个 Chris Herborth 编写的 hey 入门指南


notify shows a notification panel with a message. There are various parameters that are described when you call notify --help. A notification can also be used to show the progress of some action. When doing that, it's important to set a messageID and always use it when you update the progress (a float between 0.0 and 1.0 that's printed as percent). Otherwise you'll see several notification panels if you update quicker then the set timeout.
An example:

notify --type progress --group "--group" --title "--title" --icon /boot/home/bebook.hvif \
--messageID MyMessageID --progress .75 "Keep waiting"



query 是查询面板的命令行版本。实际上,一个创建搜索项目的快速方式是在搜索面板创建一个查询,选择 by formula ,在查询词的前后添加双引号("),然后在终端或者脚本中的 query 命令之后粘贴所要查找的整个查询词。


waitfor 是一个用于等待特殊的程序或者进程启动或者终止的非常好的方式。

index 其他命令


checkfs是一个非常重要的工具,主要用于检查文件系统中的错误。只需在该命令之后添加磁卷,如 /Haiku 或者设备名,它就会遍历所有的文件,然后修复所有可能出现不一致的地方。


desklink可以为任何文件,文件夹,查询或者程序在桌面栏托盘中安装图标。它也可以为相应的图标提供一个右键菜单。例如,尝试下面的脚本,为 Screenshot 添加不同的选项 (第一行中的"\" 用于在终端中进行换行):

desklink "cmd=Active window (2s):/boot/system/apps/Screenshot --window --border --delay 2" \
"cmd=Remove replicant:desklink --remove=Screenshot" /boot/system/apps/Screenshot



diskimage可用于注册普通文件作为磁盘设备。例如,您可以注册 Haiku anyboot 镜像,将其挂载在文件浏览器中,并且可以在安装器使用之前,编辑和移动其中的文件。


The launch_daemon starts all sorts of services and applications at boot-up. For some it was instructed to re-start them if they were quit. If you don't want that – maybe you'd like to test a modified Tracker, for example – you use launch_roster to stop the re-starting of the application before quitting it. Similarly, you can start it again or get info about it.c The parameter log prints out a log of all launch_daemon related events.
Without parameter, launch_roster lists all apps/services that are under its control.
For example, this will stop the re-launching of the Deskbar:

launch_roster stop


mountvolume is preferred by many to mount local partitions and disks, because its usage is so easy: just call it with the name of the partition and you're done. Try --help for more options.

mount can additionally mount remote disks by using a network filesystem, like NFS4. You specify the used filesystem with the -t parameter and the remote location with the -p parameter. As filesystem parameter you can use anything you find in /system/add-ons/kernel/file_system (and corresponding file hierarchies under ~/config or "non-packaged", of course). You also have to create a folder as mountpoint. Here's an example:

mkdir -p /DiskStation
mount -t nfs4 -p "" /DiskStation


open是一个非常小巧的工具。通过它,您可以以默认的程序打开任何文件,或者利用程序的签名还打开该程序而无需知道它的路径。它也可以用于打开网页,甚至“虚拟” 的目录, . 用于当前目录或者 .. 用于上层目录,并且可以在 Tracker 中打开相应的文件夹。


A ramdisk is like a harddisk running only in the computer's memory. That makes it very fast but also volatile, because its contents vanishes when you shut down the computer, or it crashes or you experience a blackout.
To create a ramdisk of 1 GiB, format to the name "RAMses" and mount it, you enter this in Terminal or create a script of it:

ramdisk create -s 1gb
mkfs -q -t bfs /dev/disk/virtual/ram/0/raw RAMses
mountvolume RAMses

Note: When creating a ramdisk, the ramdisk command prints out the path to it. If you create several disks, that path /dev/disk/virtual/ram/0/raw will change!

To preserve the contents, at least if no calamity like a blackout etc. strikes, a ramdisk can be set up to read/write an image on the harddisk. For that, you need to supply a file of the desired size that will be read from every time you start your ramdisk, and written to when you unmount it. To create an image file "RAMimage" of 500MiB and format it, do this:

dd if=/dev/zero of=RAMimage bs=500M count=1
mkfs -q -t bfs /dev/disk/virtual/ram/0/raw RAMimage

From now on, you start the ramdisk like this:

ramdisk create RAMimage
mountvolume RAMimage

It's very important to always cleanly unmount you ramdisk, either from Tracker or with unmount /RAMimage, or the changes won't be written back to the image file!