If you have ever tried to clear tmp on Mac and wondered whether it is actually safe, you are not alone. The /tmp directory — which is really just a symlink to /private/tmp on macOS — accumulates scratch files from apps, installers, Xcode builds, and system services. On a busy developer machine it can balloon to several gigabytes. This guide explains exactly what lives there, what you can safely remove, and how to do it without destabilising your system on macOS Sequoia or Tahoe, whether you are on Apple Silicon or Intel.
What Is /tmp on Mac and Where Does It Actually Live?
macOS follows POSIX convention and exposes /tmp at the root of the filesystem. In practice, /tmp is a symbolic link that points to /private/tmp, which is the real directory. You can confirm this yourself:
ls -la /tmp
You should see output like /tmp -> private/tmp. Both paths reach the same files. The directory is world-writable with the sticky bit set, meaning any user or process can create files there, but only the owner of a file (or root) can delete it.
macOS does not guarantee an automatic cleanup schedule the way Linux's systemd-tmpfiles does. Instead, the OS clears /private/tmp on every reboot — but reboots on Apple Silicon Macs are infrequent, so files can accumulate for weeks or months between restarts.
What Kinds of Files Accumulate in /private/tmp?
The contents vary by how you use your Mac. Common categories include:
- Installer staging files — package installers (.pkg) expand payloads here before copying them to their final destinations.
- Xcode build intermediates — some older build scripts and code-signing steps write temporary outputs to
/tmp. (Most Xcode intermediate products land in~/Library/Developer/Xcode/DerivedDatainstead.) - Shell script scratch files — any script that calls
mktempcreates a uniquely-named file or directory here. - App crash data and lock files — some third-party apps write lock files (
.lock,.pid) or temporary logs to/private/tmp. - Compiler and linker temps — Clang, Rust (via
~/.cargofor cache, but/tmpfor in-process intermediates), and Java tools (separate from~/.m2/repository) all use it during compilation. - Homebrew install tarballs — Homebrew extracts source archives to a subdirectory under
/tmpbefore building bottles.
How Much Space Can /private/tmp Use? A Sizing Reference
| User profile | Typical /private/tmp size | Main contributors |
|---|---|---|
| Casual user (light app use, infrequent reboots) | 50 MB – 300 MB | App update staging, occasional installer leftovers |
| Developer (Xcode + Homebrew, compiles weekly) | 500 MB – 3 GB | Homebrew build tarballs, Clang/linker temps, code-signing intermediates |
| Heavy CI / build automation (long uptime) | 3 GB – 10 GB+ | Parallel build jobs, test runner scratch, Docker layer staging |
If your Mac has been running for months without a reboot, auditing /private/tmp is one of the first things worth doing when you are trying to free up space on Mac.
Is It Safe to Delete Files in /private/tmp?
In general, yes — with one important caveat. Files in /private/tmp that belong to a currently running process should not be deleted while that process is active. Deleting a lock file mid-run can confuse the application that owns it. Deleting an in-progress installer's staging directory can corrupt the install.
The safest approach is:
- Quit all open applications and stop any running builds or package installs.
- Check whether any processes have files open in
/private/tmpbefore deleting anything. - Delete only files you are confident are orphaned (i.e., no running process owns them).
Rebooting is the zero-risk option — macOS clears the directory automatically on boot. If you want to clear it without rebooting, the manual steps below are the next best thing.
How to Clear /private/tmp on Mac Manually (Step-by-Step)
Step 1: Check what is actually there
Open Terminal and list the contents with sizes:
sudo du -sh /private/tmp/* 2>/dev/null | sort -rh | head -30
This shows the largest items first. Note any directories with recognisable names from apps you use actively — do not remove those yet.
Step 2: Identify open file handles in /private/tmp
Run this to see which processes currently have files open there:
sudo lsof +D /private/tmp 2>/dev/null
If the output is empty (or shows only your Terminal session), it is safe to proceed with cleanup. If you see other processes, quit them first or wait until they finish.
Step 3: Remove orphaned files and directories
Delete everything older than 24 hours that no running process has open:
sudo find /private/tmp -mindepth 1 -mtime +1 -exec rm -rf {} + 2>/dev/null
The -mindepth 1 flag prevents the command from attempting to remove /private/tmp itself. The -mtime +1 filter skips files modified within the last day, which reduces the chance of touching something in active use.
Step 4: Verify the result
du -sh /private/tmp
You should see a much smaller number. On a developer machine that hasn't been rebooted in months, this single step can reclaim several gigabytes.
What to Leave Alone in /private/tmp
Some files in /private/tmp look orphaned but are actually important for a running session:
- SSH agent sockets —
ssh-XXXXXX/agent.NNNdirectories are created byssh-agentand your shell relies on them during the current login session. - Launchd socket files — certain daemons register UNIX domain sockets under
/private/tmp. Deleting them forces the service to restart (usually harmless but occasionally disruptive). - Running installer payloads — if a
.pkgis installing right now, its staging directory must not be touched.
When in doubt, reboot — it is the cleanest and safest option.
/tmp vs. Other Temp Locations on Mac: Know What You Are Cleaning
macOS spreads temporary and cached data across several locations. Clearing only /private/tmp often misses the larger space hogs. Here is a quick map:
/private/tmp— system-wide temp files, cleared on reboot.~/Library/Caches— per-user app caches; safe to clear on a per-app basis. See our guide on how to clear system cache on Mac for details.~/Library/Developer/Xcode/DerivedData— Xcode build products; can grow to 20–50 GB on active projects.~/.cargo/registry— Rust crate source cache (not a temp dir, but often forgotten).~/.m2/repository— Maven artifact cache for Java projects./var/folders— per-user temporary files managed by launchd; macOS auto-expires entries here, so manual cleanup is rarely needed.
If you want a single view of all these locations, a tool like Crumb can audit all of them at once and show what is safe before you delete anything — particularly useful when you are trying to understand what is actually eating your disk.
Automating /private/tmp Cleanup Without Surprises
Rather than running manual commands each month, you can create a launchd agent that removes old files on a schedule. Save the following plist to ~/Library/LaunchAgents/com.user.tmpcleaner.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.tmpcleaner</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/find</string>
<string>/private/tmp</string>
<string>-mindepth</string>
<string>1</string>
<string>-mtime</string>
<string>+7</string>
<string>-exec</string>
<string>rm</string>
<string>-rf</string>
<string>{}</string>
<string>+</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>3</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
Load it with:
launchctl load ~/Library/LaunchAgents/com.user.tmpcleaner.plist
This runs every night at 3 AM and removes any file or directory in /private/tmp not modified in the past seven days. The seven-day window gives long-running installs or background jobs time to finish before their scratch files are swept away.