How to Enable Safe Mode from the Command Line on a Mac

Sep 4, 2014 - 4 Comments

Safe Boot Mode on a Mac Troubleshooting complex issues on a Mac can be challenging as is, and if you’re ever confronted with some complex situations you may find the command line to lend a major hand. In this case, advanced users can boot a Mac into safe mode through the usage of the nvram utility, a tool which allows users to directly manipulate firmware variables. We’ll use nvram to enable safe booting entirely through the command line, preventing a user from needing to use the standard Mac method to boot into safe mode by holding down a Shift key upon system start of OS X, this opens the door for remotely enabling safe mode and improved remote troubleshooting, and for a variety of scripting applications.


This is a trick with fairly advanced application, so most users will never need to use this. Nonetheless, nvram command allows for truly remote troubleshooting, or for situations where there is an issue with a Mac keyboard and USB interfaces that are preventing the Shift key to be used for safe booting as is usual.

The command sequence to enable safe mode through the terminal with nvram is as follows:

sudo nvram boot-args="-x"

Note this is applying a boot argument so that safe mode is set to always be enabled, meaning until it has been specifically disabled again, every boot will be ‘safe’ with all the accompanying limitations.

After your troubleshooting is complete, you will want to remove the boot-arg from firmware so that the Mac can boot as normal and behave as normal again, that can be done by clearing boot-args with the following command string:

sudo nvram boot-args=""

You can also check the current nvram boot arguments with the following command:

nvram boot-args

If it’s cleared, you’ll see an error message indicating no variable was found.

Terminal in OS X

This can obviously be used directly from the local terminal of OS X, but to be able to use this nvram command for remote management purposes on a different machine, the target Mac would need to have enable the SSH server to allow for a remote login to administer the Mac.

The -x boot-arg can also be used in conjunction with the -v argument to combine booting safe mode with always booting verbose mode, though how useful verbose booting is on a remotely administered Mac is questionable.

I’ve had to use this trick when troubleshooting a Mac with mysterious erroneous behavior that had nonfunctioning keyboards and USB interfaces, eventually it was discovered the Mac had water contact, and the machine eventually recovered after drying out. In that case the troubleshooting tricks weren’t necessary, but there are plenty of situations where they would be.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

4 Comments

» Comments RSS Feed

  1. Michael Durio says:

    Problem is, this doesn’t work at all if you’ve enabled FileVault. Needed to boot into safe mode yesterday after finally enabling FV on my MBP. Had to research online to find out that the boot args don’t apply once FileVault is enabled. That’s a closely guarded secret, apparently.

    • Drew Baron says:

      It worked for me on a FileVault 2 enabled machine. I just did it today to fix a Yosemite problem. I had to use this because the usual keyboard shortcut does NOT work with FileVault.

  2. Adrian Chamberlain says:

    Awesome – thank you. Tried out the public Beta Yosemite and found a certain application didn’t worked so I went back to Mavericks with Time Machine. When I did the time machine backups it crawled. I mean crawled. Long story of what I tried for that and came across a post for going into safe boot to do a normal timed backup ( which worked by the way :) ). Anyhow, couldn’t get the shift key safe boot to work. The command did. Thank you! :)

  3. Tim says:

    I have a water damaged MacBook Pro that will only boot into safe mode. This is great to make it do this automatically! Question: Is there a way to enable specific services. I would really like to enable DVD playback, for example. Thanks!

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates