macOS Commands
13 minute read
Syntax, options, and examples for every barn mac subcommand. The machine model, networks, JSON results, and failure reasons these commands share are defined in the Mac Runtime Reference; a guided first run is in macOS Virtual Machines.
Common rules
- Host. The commands need an Apple Silicon Mac on macOS 27 or later with the matching
Barn.app, run as the logged-in desktop user (requirements). At most two macOS VMs run at a time per Mac; starting a third fails withmac_vm_limit. - Machine names. A command with an optional
[name]uses the only existing machine, ormac1. With several machines and none namedmac1, pass a name.configure,recreate, anddestroyalways need one.startandstoptake several names or--all, not both. - Sizes.
--memoryand--diskare binary even when writtenGB:16G,16GiB, and16GBall mean 16 GiB, and a bare number is bytes. Linux inventoryGBis decimal. - Confirmation.
recreateanddestroyprint what they will delete and ask you to type the command name.--yesor--forceskips the question and is required without a terminal; neither command has a-yshorthand. Commands that download macOS from Apple (up,setup,image update) ask first;-y/--yesskips that question and is required without a terminal. - State. Machines live under
$BARN_HOME/mac, separate from the Linux inventory. These commands ignore the LinuxBARN_IMAGE/BARN_ARCH/BARN_CPU/BARN_MEM/BARN_SCALE/BARN_DISKoverrides.
Every option below has been available since 1.1.0.
barn mac ls
Start here to see what exists: every machine with its state, address, SSH readiness, macOS build, resources, and shares.
It reads local records and queries running machines; it never creates, downloads, or starts anything. barn mac without a subcommand runs ls. The JSON shape is in ls output.
Aliases: list, status, st.
No local options beyond --help; global presentation options still apply.
barn mac up
Use up to get a machine running: it creates the machine the first time, starts it afterwards, and returns once SSH and passwordless sudo work.
The default name is mac1. On a Mac without a prepared macOS base, up first downloads the restore image from Apple after you confirm and installs it once; later machines clone that base in seconds. A --disk size that differs from the prepared base’s capacity installs a matching base first.
Creation options apply only to a new machine. On an existing machine up just starts it; an option that differs from the recorded setting fails with mac_configuration_conflict, and the next: line prints the command to use instead. --share names default to the folder’s last path component, and ~/ expands to your home directory.
--no-wait returns once the VM is running. On a first boot, provisioning may still be in progress; run barn mac up NAME again to wait for SSH and finish initialization before using ssh or exec.
| Option | Meaning / default | Available in |
|---|---|---|
--clipboard on|off | on/off, true/false, or yes/no; default on, active while the desktop window is focused | 1.1.0 |
--cpu int | vCPUs, default 4; minimum 2, maximum host logical CPU count | 1.1.0 |
--disk size | Base capacity, minimum 32 GiB; default uses the prepared base, or 100 GiB initially | 1.1.0 |
--ipsw string | install macOS from this restore image instead of downloading from Apple | 1.1.0 |
--memory size | Memory, default 8 GiB; a whole MiB from 4 GiB to host RAM | 1.1.0 |
-n, --no-wait | return once the VM runs; first boot may still be initializing | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
--share [name=]path[:ro] | Repeatable [name=]path[:ro|:rw]; default writable, mounted under /Volumes/My Shared Files | 1.1.0 |
--subnet string | Canonical private /24, or auto; default selects the first free subnet | 1.1.0 |
--user string | Guest administrator; default is the host username, or barn if that name is invalid | 1.1.0 |
-y, --yes | download macOS from Apple without asking (required without a terminal) | 1.1.0 |
barn mac start
Use start to boot machines that have already completed their first up. It waits for SSH and never creates a machine or downloads anything.
Select names or --all, not both. A machine that has not finished its first boot fails with mac_not_initialized: if it is running, watch its first boot with barn mac open NAME; if it is stopped, continue with barn mac up NAME --open. --recovery boots macOS Recovery with its desktop shown and does not wait for SSH.
| Option | Meaning / default | Available in |
|---|---|---|
--all | start every machine | 1.1.0 |
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
--recovery | boot macOS Recovery and show its desktop | 1.1.0 |
barn mac stop
Use stop to shut machines down cleanly through macOS; disks and settings stay as they are.
A machine that has not stopped after two minutes is powered off, and the result says so ("forced": true). --force powers off at once, like holding the power button; unsaved work in the guest is lost.
| Option | Meaning / default | Available in |
|---|---|---|
--all | stop every machine | 1.1.0 |
--force | Power off immediately instead of requesting shutdown; unsaved guest work is lost | 1.1.0 |
barn mac restart
Use restart to apply settings saved with configure, or to reboot a guest that misbehaves.
It shuts the machine down normally and starts it again. It takes at most one name and has no --all.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--open | show the desktop as soon as the VM runs | 1.1.0 |
barn mac configure
Use configure to change a machine’s CPUs, memory, shared folders, network, or clipboard setting without touching its disk or account.
CPUs, memory, shared folders, and the subnet change only while the machine is stopped; otherwise the command fails with mac_running. The clipboard setting can change anytime. Saved configuration, including a clipboard change, applies at the next start; to toggle clipboard sharing for the current session, use the menu bar.
Omitted options keep their values. --share adds a share or replaces the share of that name; --unshare removes one. --subnet auto moves the machine to the first free subnet, which is the fix for mac_subnet_in_use.
| Option | Meaning / default | Available in |
|---|---|---|
--clipboard on|off | on/off, true/false, or yes/no; omitted retains the setting | 1.1.0 |
--cpu int | vCPUs, minimum 2 and maximum host logical CPU count; omitted retains current value | 1.1.0 |
--memory size | Memory, a whole MiB from 4 GiB to host RAM; omitted retains current value | 1.1.0 |
--share [name=]path[:ro] | Add or replace a named share; repeatable, writable by default, optional :ro or :rw | 1.1.0 |
--subnet string | move to this private /24 network, or auto for the first free one | 1.1.0 |
--unshare stringArray | stop sharing the named folder (repeatable) | 1.1.0 |
barn mac recreate
Use recreate to get a clean disk from the base image while keeping the machine’s name and settings, or, with --update, to move the machine to the newest prepared macOS.
recreate erases the machine’s disk: files, apps, and settings inside the guest are lost. Shared folders on the host are untouched. Copy anything you need off the guest first.
The new machine keeps its name, account, CPUs, memory, disk capacity, shared folders, clipboard setting, and address, and gets a new login password and new SSH keys.
--update clones the default base that barn mac image update prepared, at the machine’s own disk capacity. If the new macOS build is prepared only at another capacity, prepare it first, for example barn mac setup --disk 200G.
| Option | Meaning / default | Available in |
|---|---|---|
--force | skip the confirmation (required without a terminal) | 1.1.0 |
-n, --no-wait | return once the VM runs, without waiting for SSH | 1.1.0 |
--update | use the newest prepared macOS base | 1.1.0 |
--yes | Same as --force; no -y shorthand | 1.1.0 |
barn mac destroy
Use destroy to delete machines you no longer need.
destroy powers each named machine off and deletes its disk, SSH keys, password, and settings. The shared macOS base, other machines, and shared folders on the host are kept.
Explicit names are required. Run barn mac image prune afterwards to remove bases that no machine uses.
| Option | Meaning / default | Available in |
|---|---|---|
--force | skip the confirmation (required without a terminal) | 1.1.0 |
--yes | Same as --force; no -y shorthand | 1.1.0 |
barn mac open
Use open to see and use the machine’s desktop; it starts a stopped machine first.
Closing the window keeps the machine running in the background, and the clipboard is shared while the window is focused. A running machine that has not finished its first boot can be watched here; for a stopped one, use barn mac up NAME --open.
No local options beyond --help; global presentation options still apply.
barn mac ssh
Use ssh for an interactive shell in the machine, or to run a shell command line in it.
Without a command, ssh opens an interactive session. A command after -- is joined into one line for the guest shell, as plain ssh does, and its exit status is returned. Argument rules are in SSH and exec.
No local options beyond --help; global presentation options still apply.
barn mac exec
Use exec in scripts: it runs one program with its arguments passed exactly as given and returns the program’s exit status.
A command after -- is required. Use sh -c explicitly for pipelines and other shell expressions. With --json the result carries exit_code, stdout, and stderr. Argument rules are in SSH and exec.
No local options beyond --help; global presentation options still apply.
barn mac password
Use password when the guest desktop asks for the login password, at the lock screen or an administrator prompt.
The password is stored next to the machine’s SSH key with the same protection. --copy puts it on the clipboard instead of printing it.
| Option | Meaning / default | Available in |
|---|---|---|
-c, --copy | copy to the clipboard instead of printing | 1.1.0 |
barn mac ssh-config
Use ssh-config to let ssh, scp, rsync, and editors reach each machine by name, with its own key and pinned host key.
Without options it prints the OpenSSH fragment. The first machine to become ready installs the fragment as one Include in ~/.ssh/config, and lifecycle commands keep it current. --remove deletes only what Barn installed and keeps it out until --install. A name that ~/.ssh/config already uses for another host is published by address only. If ~/.ssh/config is a symlink or hard link, the command fails with ssh_config_linked and prints the Include line for you to add.
--install and --remove are mutually exclusive. This command takes no machine names.
| Option | Meaning / default | Available in |
|---|---|---|
-i, --install | install the entries as one Include in ~/.ssh/config | 1.1.0 |
--remove | remove the entries Barn installed | 1.1.0 |
barn mac logs
Use logs when a machine fails to start, loses its network, or does not shut down: it shows the last lines of the machine’s runtime log, including Apple Virtualization errors.
--lines/-n must be positive and defaults to 100. Here -n means lines, not no-wait. There is no follow option.
| Option | Meaning / default | Available in |
|---|---|---|
-n, --lines int | number of recent lines (default 100) | 1.1.0 |
barn mac setup
Use setup to prepare the macOS base ahead of time, for example in a provisioning script, so the first up only has to clone it.
It downloads macOS from Apple after you confirm, or reads --ipsw, and installs it once into the unbooted base that every machine is cloned from. up does the same automatically when no base is prepared.
| Option | Meaning / default | Available in |
|---|---|---|
--disk size | Base capacity, at least 32 GiB. Defaults to the current base capacity or 100 GiB for the first base | 1.1.0 |
--ipsw string | install macOS from this restore image instead of downloading from Apple | 1.1.0 |
-y, --yes | download macOS from Apple without asking (required without a terminal) | 1.1.0 |
barn mac image ls
Use image ls to see which restore images and bases take up disk space, and which machines use them.
It lists each restore image and base with its state and disk usage. It reads local state only and does not start the native runner.
Aliases: list.
No local options beyond --help; global presentation options still apply.
barn mac image update
Use image update to move to Apple’s newest macOS 27 build.
It asks Apple for the newest macOS 27 restore image, downloads it after you confirm, and installs it as the default base for new machines. Existing machines keep their base until you run barn mac recreate NAME --update.
| Option | Meaning / default | Available in |
|---|---|---|
--ipsw string | use this restore image instead of downloading from Apple | 1.1.0 |
-y, --yes | download without asking (required without a terminal) | 1.1.0 |
barn mac image prune
Use image prune to reclaim disk space from bases that no machine uses.
It lists unused bases other than the current default. --installers adds downloaded restore images and partial downloads. Nothing is deleted without --yes.
| Option | Meaning / default | Available in |
|---|---|---|
--installers | include downloaded restore images and partial downloads | 1.1.0 |
-y, --yes | Delete the listed unused images; otherwise only list candidates | 1.1.0 |
barn mac doctor
Run doctor first when something goes wrong, and after installing or upgrading Barn.
It checks macOS and Apple Silicon support, the Mac component’s signature, free disk space, the prepared base, and every machine: its files, keys, shared folders, network, and SSH. It changes nothing and starts nothing, and exits 3 if any check fails.
No local options beyond --help; global presentation options still apply.