Skip to content
Haiku OSHow-To Published Updated 6 min readViews unavailable

How to Use Haiku's Terminal and Shell Environment

Use Haiku Terminal, Bash profiles and native filesystem tools safely, write portable scripts, and separate POSIX habits from Linux assumptions.

Haiku Terminal starts Bash by default and exposes a large POSIX/GNU-style command environment alongside Haiku-native tools for BFS attributes, indexes, devices, teams, packages, and application launching. Familiar shell concepts transfer well; Linux-specific command options, filesystem paths, service managers, and configuration recipes do not automatically transfer.

Learn Terminal before changing the shell

Open Deskbar → Applications → Terminal. Create another window with Alt+N, a tab with Alt+T, and switch to a numbered tab with Alt plus its number. Alt+Enter toggles full screen.

Settings changed directly through some menu items apply only to the current session unless saved as default or applied through Settings → Settings…. Enable confirmation when closing a window with active programs; closing Terminal can send hangup/termination consequences to foreground jobs.

Haiku Terminal has useful Tracker integration. Dragging a file/folder into the terminal inserts its safely represented path; right-drag offers insert path, change directory, link, move, or copy actions. Holding Alt over a displayed path/URL highlights it for opening or copying. Review a move/copy choice before releasing the mouse—this is a real filesystem action, not text completion.

Use open to hand a file, URL, or directory to its preferred application:

open .
open document.txt

Orient yourself in Haiku’s filesystem

Start every unfamiliar session with non-destructive checks:

pwd
uname -a
getarch
printf '%s\n' "$HOME"
printf '%s\n' "$PATH"

/boot/home is the normal home hierarchy and /boot/system is the system packagefs view. Much of /boot/system is effectively read-only because activated HPKGs form it virtually. Writable settings, cache, variable data, and non-packaged paths are deliberate exceptions documented in the filesystem guide.

Do not try to fix a permission error under package-managed directories with recursive chmod, chown, or root-like assumptions. Install software with package management or place genuinely unpackaged user/system additions in the appropriate non-packaged hierarchy.

Quote paths and variables:

cd "$HOME/config/settings"
printf '%s\n' "$file"
rm -- "$file"

Unquoted expansions can split on whitespace or expand wildcard characters. A filename beginning with - can be parsed as an option unless the command supports and receives --.

Verify commands instead of assuming Linux flags

Basic tools such as ls, find, grep, sed, awk, and Bash are familiar, but the installed versions and option sets matter. Inspect them locally:

type -a grep
grep --version
ps --help

The old article prescribed ps aux; that BSD-style shorthand is not a portable POSIX promise and may differ with Haiku’s current ps. Use the installed help and select only required fields/options.

Similarly, Bash is not the entire “Linux command line.” Many commands are separate programs, and Linux-only tools such as systemctl, /proc recipes, distribution package managers, and Linux device names do not describe Haiku. Check the official command list and Haiku service/package documentation.

Work with BFS attributes correctly

listattr inventories attributes on a file; catattr reads one named attribute. The previous article incorrectly described catattr filename as listing all attributes.

listattr -l photo.jpg
catattr BEOS:TYPE photo.jpg
addattr -t string Photo:Processed yes photo.jpg
catattr Photo:Processed photo.jpg

Attribute values have types. Use a stable namespaced name and consistent type, and practice on copies. rmattr removes a field; assigning an empty string is not the same operation.

BFS attributes may disappear when copying through a non-BFS filesystem, generic archive, or protocol. After a round trip, use listattr to verify rather than assuming file contents imply metadata preservation.

Query indexes from Terminal

Haiku’s query command evaluates a BFS query formula, comparable to Tracker’s formula Find mode. The target attribute must be indexed on each searched BFS volume. First inspect the volume’s indexes:

cd /boot/home
lsindex -l
query 'BEOS:TYPE=="text/plain"'

Construct complex criteria in Tracker’s Find window, switch to formula mode, and copy the generated expression instead of guessing quoting/grammar. Keep the entire formula single-quoted so the shell does not expand wildcard characters or variables.

A query result path is the real file. Deleting or moving it changes the underlying object. Test scripts on a disposable directory and print matches before applying a mutating loop.

Manage packages with current commands

Search and inspect before installing:

pkgman search PACKAGE_TERM
pkgman info PACKAGE_NAME
pkgman install PACKAGE_NAME

Review repository origin, architecture, dependencies, and proposed changes. For inventory, current pkgman uses pkgman search -a -i -D; there is no pkgman list command. Reserve full-sync for official release/repository reconciliation procedures because it can downgrade or remove packages.

Never pipe an unreviewed network script directly into Bash. Download to a new file, verify authoritative source and checksum/signature where available, read it, and run with only the permissions required.

Configure Bash in Haiku’s documented locations

The user guide identifies these per-user files:

~/config/settings/profile
~/config/settings/inputrc

They add to or override defaults under /boot/system/settings/etc/. Haiku loads the user profile whenever a new Terminal is opened. The blanket ~/.profile/~/.bashrc advice in the previous post was therefore misleading for Haiku’s documented setup.

Back up the profile, then add small guarded changes:

export EDITOR=nano
alias ll='ls -la'

Open a new Terminal to test. Keep an existing known-good tab open while editing so a syntax error or bad PATH can be repaired. Append to PATH rather than replacing system entries blindly, and never put the current directory first on a privileged search path.

inputrc controls Readline key bindings. Haiku already supplies useful defaults; change it only for a tested need. Terminal visual settings/themes belong to Terminal’s Settings UI and ~/config/settings/Terminal, not the Bash profile.

Write scripts with an honest interpreter contract

Use #!/bin/sh only for syntax supported by the system’s sh contract. If arrays, [[ ... ]], Bash-specific expansion, or other Bash features are required, declare Bash explicitly:

#!/bin/bash
set -e

Do not assume set -e makes a script safe; its behavior has contextual exceptions. Check every destructive input, quote expansions, use temporary directories securely, handle partial failure, and provide a dry-run for bulk operations.

An attribute loop should reject missing files and show intent before writing:

#!/bin/sh
for file in ./*.jpg; do
    [ -e "$file" ] || continue
    printf 'tagging %s\n' "$file"
    addattr -t string Photo:Processed yes "$file" || exit 1
done

Run sh -n script for a syntax check, test in a disposable folder, and compare attributes afterward. Syntax success is not semantic validation.

Start applications at boot without blocking startup

Haiku now uses launch_daemon for system services, but the user guide documents ~/config/settings/boot/UserBootscript for user commands after boot. Long-running applications placed there must normally be backgrounded or the script waits until they exit.

For simple application autostart, the guide recommends links in ~/config/settings/boot/launch, which avoids hand-written shell logic. Do not convert a network daemon or privileged service into an ad hoc UserBootscript entry; use its Haiku launch configuration.

The same guide marks UserShutdownScript and UserShutdownFinishScript as not yet working. Do not build backup integrity or cleanup guarantees on those hooks.

Capture evidence when a command fails

Record the exact command, current directory, environment values relevant to it, exit status, standard error, Haiku revision, architecture, package version, and minimal input. Avoid pasting tokens, private paths, or entire environment dumps into public tickets.

The productive mental model is “Bash plus Haiku,” not “Linux with different wallpaper.” Portable shell habits remain valuable; native paths, packagefs, attributes, queries, launch services, and actual command help define the parts that must be learned locally.

Related:

Sources:

Comments