# How to clear System Data with Terminal, safely

Guide · Updated 22 November 2026. By Mohit Nippanikar, who makes SiftMac.

## The short answer

- **Yes, Terminal can do it**, part by part: measure with `du`, remove Time Machine local snapshots with `tmutil`, clear app caches with the app quit, and let Xcode and Docker clean up after themselves with their own commands.
- **What it costs you:** caches rebuild and snapshots come back within the hour, so the space you win there is temporary. Old simulators, Docker build cache and crash reports stay gone.
- **Never:** `sudo rm` anything under `/System`, `/private/var/vm`, `/private/var/db` or `/private/var/folders`. Those belong to macOS, and there’s no undo in Terminal.

## 1. Before you start

1. **Give Terminal Full Disk Access** in System Settings › Privacy & Security › Full Disk Access. Without it, `du` skips protected folders and you underestimate what’s there. Turn it off again when you’re done.
2. **Note the free space**, so you can see what each step won:

```
df -h /System/Volumes/Data
```

Paste one command at a time and read what it printed before the next. Every command here works on macOS 14 Sonoma and later, Tahoe and macOS 27 included. Nothing on this page needs you to turn off System Integrity Protection; if a guide tells you to, close it.

## 2. Measure: where the space is

Your files, apps and System Data live on the Data volume, mounted at `/System/Volumes/Data`. Measure that, one level deep, biggest last:

```
sudo du -xh -d1 /System/Volumes/Data 2>/dev/null | sort -h | tail -20
```

`-x` keeps `du` on that one volume, so it doesn’t wander into external drives or count the sealed system volume. It takes a few minutes. Then follow the biggest entry down. The two that usually matter for System Data:

```
du -xh -d1 ~/Library 2>/dev/null | sort -h | tail -15
sudo du -xh -d1 /System/Volumes/Data/private/var 2>/dev/null | sort -h | tail -10
```

The first finds what your apps keep in your Library. The second shows macOS’s own working folders, which you’ll mostly leave alone; it’s useful for spotting a runaway log or a huge `folders` entry. Totals won’t match Storage settings exactly, because APFS clones share space that `du` counts twice.

## 3. Time Machine local snapshots

List them:

```
tmutil listlocalsnapshots /
```

Each line looks like `com.apple.TimeMachine.2026-11-22-101010.local`. You have three ways to free them, from gentlest to most thorough:

```
sudo tmutil thinlocalsnapshots / 20000000000 4
sudo tmutil deletelocalsnapshots 2026-11-22-101010
sudo tmutil deletelocalsnapshots /
```

The first asks macOS to reclaim about 20 GB (the figure is in bytes) at the highest urgency, 4, by thinning snapshots. The second deletes the snapshot with that date and time; use one from your own list. The third deletes every local snapshot on the startup disk. None of them touches the backups on your Time Machine drive. With Time Machine on, a new snapshot appears within the hour, so do this when you need the room now, not as routine.

## 4. App caches, logs and crash reports

Find the big caches first:

```
du -sh ~/Library/Caches/* 2>/dev/null | sort -h | tail -10
```

Quit the app that owns one, then empty its folder rather than deleting the folder itself. For example, with Chrome quit:

```
rm -rf ~/Library/Caches/Google/Chrome/*
```

Type the full path yourself, check it with `ls` first, and never build it from a variable: if the variable is empty, the command becomes `rm -rf /*`. Tools with their own cache command should use it:

```
brew cleanup --prune=all
npm cache clean --force
```

Old crash reports are safe to remove; apps write new ones when they crash:

```
rm -rf ~/Library/Logs/DiagnosticReports/*
```

Leave `/Library/Caches` and anything starting with `com.apple` alone unless you know what it is. macOS clears its own caches and logs when it needs space.

## 5. Xcode, simulators and Docker

Simulators for runtimes you no longer have installed:

```
xcrun simctl delete unavailable
```

That removes only simulator devices whose runtime is gone. `xcrun simctl list devices` shows the rest; delete those from Xcode’s Devices and Simulators window. Whole simulator runtimes are managed in Xcode’s Settings › Components. With Xcode quit, build data can go too, since Xcode rebuilds it:

```
rm -rf ~/Library/Developer/Xcode/DerivedData/*
```

Docker Desktop’s disk image is never deleted by hand. Ask Docker what it can give back, then let it do the work:

```
docker system df
docker system prune
docker builder prune
```

`docker system prune` lists what it will remove and asks first. It keeps volumes, where databases live, unless you add `--volumes`.

## 6. What never to delete from Terminal

| Path | What it is | Why not |
| --- | --- | --- |
| `/System` | macOS itself, on a sealed read-only volume | Signed and protected; it can’t be cleaned this way |
| `/System/Volumes/VM`, `/private/var/vm` | Swap files and the sleep image | In use while the Mac runs; a restart clears swap |
| `/private/var/db` | System databases, the unified log, Spotlight and update data | macOS manages it; deleting parts can break updates or logins |
| `/private/var/folders` | Per-user temporary files and caches | Running apps have files open there; a restart clears what’s safe |
| `~/Library/Mobile Documents`, `~/Library/CloudStorage` | iCloud Drive and other cloud folders | Deleting here can delete from the cloud too |
| `~/Library/Containers`, `~/Library/Group Containers` | Apps’ own data, not just caches | Chats, libraries and settings live here |

And skip `sudo purge`: it empties the memory cache, not the disk, so System Data doesn’t move.

## Questions

### Is sudo rm -rf safe for clearing System Data?

Not on system paths, and it’s never needed there. Use `tmutil`, `xcrun simctl`, `docker` and each tool’s own clean command. Use plain `rm -rf` only on a folder’s contents in your own Library, with the app quit.

### Which Terminal command frees the most System Data?

It depends on the Mac, which is why you measure first. Local snapshots, iPhone backups, Docker and old simulators are the usual big ones; caches rarely are.

### Why does Terminal say “Operation not permitted”?

Either Terminal doesn’t have Full Disk Access, or the path is protected by System Integrity Protection. The first you can change in Privacy & Security; the second is macOS telling you to leave that path alone.

### Does the purge command free storage on a Mac?

No. `purge` flushes the disk cache held in memory. It doesn’t delete anything on the disk.

## How SiftMac handles it

SiftMac does the measuring for you and takes the same safe line: its System Data view removes old macOS installers and device update files when you pick them, moves iPhone and iPad backups to the Undo Shelf for 7 days, and leaves snapshots to macOS and Docker’s disk image to Docker. With **Include Docker** on, Docker’s unused images and build cache appear under Developer files, freed with Docker’s own commands.

Download: https://siftmac.com/SiftMac.dmg (scanning is free, and so is the first 2 GB of cleaning).

## Sources

- [tmutil(8) manual page](https://keith.github.io/xcode-man-pages/tmutil.8.html)
- [Apple: About Time Machine local snapshots](https://support.apple.com/en-us/102154)
- [Apple Developer: Downloading and installing additional Xcode components](https://developer.apple.com/documentation/xcode/downloading-and-installing-additional-xcode-components)
- [Docker Docs: docker system prune](https://docs.docker.com/reference/cli/docker/system/prune/)
- [Apple Platform Security: Signed system volume security](https://support.apple.com/guide/security/secd698747c9/web)

## Related

- [How to clear System Data on a Mac, safely](https://siftmac.com/guides/system-data-on-mac)
- [Why System Data keeps growing, and how to stop it](https://siftmac.com/guides/system-data-keeps-growing)
- [How to see what’s taking up space on your Mac](https://siftmac.com/guides/what-is-taking-up-space-on-mac)
- [Is it safe to delete Time Machine local snapshots on a Mac?](https://siftmac.com/guides/time-machine-local-snapshots)
- [Is it safe to delete Xcode simulators and CoreSimulator?](https://siftmac.com/safe-to-delete/xcode-simulators)

Canonical: https://siftmac.com/guides/clear-system-data-terminal
