Shutdown Mac from the Terminal
I spend most of the time on my Mac working from the terminal. And while there are several other ways to shutdown, restart or put the computer to sleep, I always choose to do so using the command line.
This is also useful for remote machine administration if you’re using SSH or mosh.
I know the topic seems pretty basic, and it is, but I was surprised to find out many colleagues of mine don’t use this method and thought it may be helpful for others.
To perform all three operations you can use the
shutdown command, which “Close down the system at a given time”.
$ sudo shutdown -h now
$ sudo shutdown -r now
$ sudo shutdown -s now
The command has to be run as root, so unless you’re logged in you’ll need to prefix it with
In case you want to delay the operation in X minutes, just specify the number after the
$ sudo shutdown -h +60
Will shutdown the Mac in 60 minutes.
I use these aliases in my
alias restart="sudo shutdown -r now" alias shutdown="sudo shutdown -h now" alias sleep="sudo shutdown -s now"