This guide will explain how to shut down or reboot your Mac using the command line. This can be useful if you are controlling a remote machine via SSH, if you are in single-user mode, or if you are having problems within macOS and need to bypass the GUI.
WARNING If you are using your Mac remotely and you have FileVault switched on, ensure that you run the following command before restarting:
To open the dock menu, right-click on the application icon you want to shut down or click on the item and hold. Hold an Option (Alt) button, so the Quit menu changes to Force Quit. To shut down your computer without any prompts to save or closing out applications, press and hold the Power button. Save and Quit Before Restart/Shutdown To quit all running applications before shutting down your Mac system, press and hold Ctrl + Alt + ⌘ + Power.
This is necessary because FileVault requires that you unlock your Mac with your password before macOS loads at all — which, obviously, is impossible for a remote user to do. By running
sudo fdesetup authrestart, this feature is disabled on a one-time basis.
Shut down your Mac using the command line
To shut a Mac down after a specific number of minutes, run (replacing
+ and then a number):
So, if you want a Mac to shut down after 15 minutes, you’d run:
Restart your Mac using the command line
This process is almost identical to the shutdown process, but we replace
-r in the string. So, to immediately restart the Mac, you’d run:
And to restart a Mac after a specific number of minutes (in this example, 15), you’d run:
Command To Shut Down Macbook Pro
Add a message for logged in users
If you want any logged-in users to know that the machine is being rebooted or shut down — and why — you can append a message to the end of your string. For example:
In the above example, the Mac will restart 15 minutes after the command is run, and logged-in users will see the following message:
Shutdown at Fri Feb 1 15:47:46 2019.
shutdown: [pid 26582]
*** System shutdown message from [email protected]***
System going down in 15 minutes
This Mac is being restarted so that it can finish installing crucial updates.
System shutdown time has arrived
Notice an error?
Have we got something wrong? Please let us know and we’ll fix it right away.