Safe Mode Boot Command Line Mac: How to Use It
In this article
To boot a Mac into Safe Mode using the command line, you set the NVRAM variable boot-args to include -x (or safe) and restart. This is a power-user method that works on Intel Macs and Apple Silicon Macs, though the exact steps differ slightly. This article explains the command-line approach, why you might use it, and how it compares to the standard key-based method.
What Safe Mode Actually Does
Safe Mode (also called Safe Boot) is a diagnostic startup mode that loads only the minimum software needed to run macOS. When you boot into Safe Mode, the system performs several checks and restrictions:
- Verifies your startup disk and repairs directory issues if needed.
- Loads only required kernel extensions.
- Disables all third-party startup items and login items.
- Disables user-installed fonts.
- Clears some system caches (like font caches and kernel cache).
- On Apple Silicon Macs, it also disables GPU acceleration.
This stripped-down environment helps isolate problems caused by third-party software, corrupted caches, or disk errors. If your Mac works fine in Safe Mode, the issue is likely tied to something that doesn't load there.
Why Use the Command Line Instead of Keys?
Most people enter Safe Mode by holding the Shift key during startup (Intel) or by using the power button on Apple Silicon. The command-line method is useful when:
- The Shift key isn't working or you're using a remote/virtual machine.
- You want to script the boot (e.g., for testing multiple Macs).
- You need to combine Safe Mode with other NVRAM boot arguments (like verbose mode).
- You're troubleshooting from a recovery terminal and want to set the flag before the next boot.
However, note that the command-line method doesn't work exactly the same on all Macs, and it can have side effects if not done carefully.
How to Set the Boot Argument via Terminal
The core command is nvram, which reads and writes firmware variables. To enable Safe Mode, you append -x to the existing boot-args value (or create it if it doesn't exist). Here's how:
- Open Terminal (from /Applications/Utilities/ or Spotlight).
- Check the current boot arguments:
nvram boot-args. If it returns nothing, the variable is empty. - Set the new arguments. For example:
sudo nvram boot-args="-x". If there are existing arguments, include them:sudo nvram boot-args="-x -v"(where-vis verbose mode). - Restart your Mac:
sudo reboot.
After restart, your Mac should boot into Safe Mode. To confirm, go to About This Mac > System Report and look for "Boot Mode" — it should say "Safe". You can also check with system_profiler SPSoftwareDataType in Terminal.
How to Turn Off Safe Mode via Command Line
To exit Safe Mode, you must remove the -x flag from boot-args. If you set it alone, you can delete the entire variable:
sudo nvram -d boot-argsIf you had other arguments (like -v), set them back without -x:
sudo nvram boot-args="-v"Then restart. If you don't remove the flag, your Mac will continue booting into Safe Mode every time.
Apple Silicon vs. Intel Macs
On Intel Macs, the NVRAM method works as described. On Apple Silicon (M1/M2/M3), the process is similar but with a catch: the T2 security chip and the boot policy can override NVRAM. In practice, setting boot-args via Terminal in macOS may not work if System Integrity Protection (SIP) is enabled or if the Mac has a secure boot policy set to "Full Security".
For Apple Silicon, the recommended way is still the graphical method: press and hold the power button until you see "Loading startup options", then select your disk, hold Shift, and click "Continue in Safe Mode". If you absolutely need the command line, you might need to disable SIP first (which is not recommended for security reasons) and then use nvram. However, this is fragile and not officially supported by Apple.
Common Problems and Pitfalls
- Forgot to remove the flag: Your Mac will keep booting into Safe Mode until you remove
-x. This is the most common mistake. - Existing boot-args: If you overwrite boot-args without preserving existing flags, you might lose settings like verbose mode or disable certain features. Always check first.
- NVRAM reset: Resetting NVRAM (Command+Option+P+R on Intel) will clear boot-args, which can be a way to exit Safe Mode if you can't boot normally. On Apple Silicon, you can't reset NVRAM that way, but you can use the Recovery terminal to delete boot-args.
- Safe Mode doesn't start: If the flag doesn't take effect, check if SIP is enabled. You can verify with
csrutil status. If SIP is on, the command may be ignored on Apple Silicon. - Boot loop: In rare cases, a corrupted boot-args can cause a boot loop. If that happens, boot into Recovery (hold Command+R on Intel, or press and hold power on Apple Silicon), open Terminal from the Utilities menu, and run
nvram -d boot-args.
Alternatives to Command Line
If the command-line method feels risky, use the standard methods:
- Intel Mac: Restart and immediately hold the Shift key until the login window appears.
- Apple Silicon: Press and hold the power button until "Loading startup options" appears, select your disk, hold Shift, and click "Continue in Safe Mode".
These methods are safer because they don't modify NVRAM and are automatically cleared on the next boot. The command-line approach is more for automation or when the keyboard method fails.
Frequently Asked Questions
Is the command-line Safe Mode method safe?
Yes, as long as you remove the -x flag after troubleshooting. Leaving it set will cause your Mac to always boot in Safe Mode, which is slower and disables features. If you forget, simply run sudo nvram -d boot-args and restart.
Why doesn't nvram boot-args="-x" work on my M1 Mac?
On Apple Silicon, the boot policy and SIP can ignore NVRAM boot-args. The graphical method is the reliable way. If you must use the command line, you'd need to disable SIP (not recommended) and possibly adjust the boot policy, which is complex and can leave your system less secure.
Can I combine Safe Mode with verbose mode?
Yes. Set boot-args to -x -v to see detailed log messages during boot. This is useful for diagnosing where the system hangs. Just remember to remove both flags when done.
How do I know if my Mac is in Safe Mode?
Go to About This Mac > System Report and look for "Boot Mode". It should say "Safe". Alternatively, run system_profiler SPSoftwareDataType in Terminal and look for "Boot Mode: Safe".
Will Safe Mode fix my slow Mac?
Safe Mode is a diagnostic tool, not a permanent fix. It clears caches and disables third-party software, which can temporarily speed things up, but the underlying cause (e.g., a faulty app, full disk, or aging hardware) remains. Use it to identify the problem, then address it in normal mode.