# Uninstall and Clean Up

> Remove Linux and macOS VMs deliberately, then clean up integrations, images, networking, and the application.

---

LLMS index: [llms.txt](/v1.5/llms.txt)

---

Use this page to remove part of what Barn created, or all of it. Linux labs and macOS VMs are managed separately, so `barn purge` never touches Mac VMs. Keep the `barn` CLI installed until the last step, because the cleanup commands need it.

## Choose what to remove {#choose-what-to-remove}

| Remove | Run | What is kept |
|---|---|---|
| Nothing yet, just stop the VMs | `barn stop`; `barn mac stop --all` | Everything, disks included |
| One Linux node | `barn destroy <node>` | The other nodes, that node's persistent disks, keys, images, host network |
| The Linux lab | `barn destroy` | Persistent disks, deployment keys, cached images, host network |
| The Linux lab, its persistent disks, and keys | `barn purge` (deletes immediately; `--ask` to confirm first) | Cached images, host network |
| Named Mac VMs | `barn mac destroy <name...>` (asks you to confirm) | Other Mac VMs, cached macOS images |
| Barn's SSH, `/etc/hosts`, and clock-sync integrations | [Step 2](#full-teardown-steps) | Your own `~/.ssh/config` and `/etc/hosts` entries |
| Cached images | `barn image prune --yes`; `barn mac image prune --installers --yes` | Images a VM still uses, and the default macOS base |
| The Linux host network | `barn network uninstall --yes` (after all Linux VMs are gone) | — |
| Barn itself | [Step 5](#full-teardown-steps) | `~/.barn`, until you delete it |
{.wide .expand}

Before destroying anything, check names with `barn status` (Linux) and `barn mac ls` (Mac), and copy files you want to keep to the host. [What survives each operation](../storage/#what-survives-each-operation) has the per-command detail for data disks.

## Full teardown steps {#full-teardown-steps}

1. **Destroy Linux and Mac virtual machines**

   Discard the whole Linux lab, persistent disks and deployment keys included:

   ```bash
   barn purge
   ```

   It deletes immediately. To review the VM list and scope first, run `barn purge --ask` and answer `y`/`yes` or `n`/`no`; `purge` accepts no `--yes`, `-y`, or `--force`. Then list and destroy any macOS VMs by name:

   ```bash
   barn mac ls
   barn mac destroy mac1 dev
   ```

2. **Remove SSH, `/etc/hosts`, and timer integrations**

   Destroying the whole Linux deployment already removes the default `~/.ssh/barn_config` integration. Remove anything else you installed: a custom-named SSH fragment, `/etc/hosts` entries, Mac SSH aliases, or the clock-sync user timer:

   ```bash
   barn ssh-config --remove --name lab
   barn hosts uninstall --json
   barn hosts uninstall --yes
   barn mac ssh-config --remove
   barn time auto disable
   ```

   Each command removes only the block Barn wrote.

3. **Prune cached images**

   Preview, then delete, cached Linux and macOS images:

   ```bash
   barn image prune --dry-run
   barn image prune --yes
   barn mac image prune --installers
   barn mac image prune --installers --yes
   ```

4. **Uninstall Linux host networking**

   The shared Linux host network can be removed only while no Linux VM is running. Mac VM networks go away by themselves when each VM stops.

   ```bash
   barn network uninstall --json
   barn network uninstall --yes
   ```

   On hosts that use systemd-networkd, the uninstall leaves networkd's global unit state alone when other links exist or Barn cannot confirm it is the only user; the plan reports `preserve_networkd`, and the result explains the decision in `checks.networkd`.

5. **Uninstall the Barn application and remaining state**

   If a package manager installed Barn, remove the package:

   ```bash {tab="Homebrew" group="uninstall" value="brew"}
   brew uninstall barn
   ```

   ```bash {tab="Debian / Ubuntu" group="uninstall" value="deb"}
   sudo apt remove barn
   ```

   ```bash {tab="RHEL / Fedora" group="uninstall" value="rpm"}
   sudo dnf remove barn
   ```

   - **User-scoped `install.sh`**: remove `barn`, `barn-hosts-helper`, `.barn-current`, `.barn-releases/`, and `.barn-install.lock` from `~/.local/bin`, and the `PATH` line from your shell rc file.
   - **Manual archive or source build**: with all Mac guests stopped, remove the extracted release directory, `bin/mac`, or any copied `Barn.app` (`Barn Mac.app` in `0.9.0`), plus `~/Library/Preferences/com.pgsty.barn.plist` (`io.pgsty.barn.mac-runner.plist` in `0.9.0`).
   - **Manually installed hosts helper**: if you installed `/opt/barn/libexec/barn-hosts-helper` by hand and no other user on the host uses Barn, remove it after `barn hosts uninstall --yes`.
{.steps}

> [!WARNING]
> **Delete `~/.barn` (or your custom `BARN_HOME`) only after both Linux and Mac VMs are destroyed.** It holds VM state, keys, persistent disks, and base images for both. If a VM is still running or a `destroy` failed, resolve it with `barn status` / `barn mac ls` before deleting the directory.
