A MacBook Pro open on a table next to a mug and a vase of flowers.

If you shut down your Mac in Terminal, you get more options and flexibility than using the shutdown option in the Apple menu or the power button. Here’s how you do it!

Shut Down Your Mac via Terminal

First, you have to open Terminal (or any alternative you normally use). Press Command+Space to open Spotlight Search, type “terminal,” and then select it from the search results.

RELATED: What to Do When Your Mac Won't Shut Down

Type "terminal" in the Spotlight search bar, and then click it in the results.

With terminal open, you’re ready to shut down your Mac. You’ll use the “sudo” command here; otherwise, you’ll be greeted by the error message shown below.

RELATED: How to Control sudo Access on Linux

The "NOT super-user" error message in a terminal window.

The sudo (superuser do) command, by default, gives you superuser security privileges.

To shut down your Mac, type the following command:

sudo shutdown -h <time>

Replace <time> with the specific time you want to shut down your Mac. If you want to do so immediately, type now. If you want it to shut down in an hour, type +60.

Press enter and type your password when prompted.

Type your password when prompted in terminal.

Your Mac will now shut down at the time you specified.

Restart Your Mac via Terminal

Aside from one small change, the restart process in Terminal is identical to shutting down. Press Command+Space to open Spotlight Search and search for Terminal.

RELATED: The Best "Just For Fun" Tricks Hidden in macOS' Terminal

When Terminal opens, type sudo shutdown -r <time>. Again, you must use the sudo (superuser do) command to access superuser privileges, or you’ll get the “not super-user” error message.

The "sudo shutdown -r <time>" command in a terminal window.

Replace <time> with the specific time you want your Mac to restart. If you replace <time> with now, it initiates an immediate reboot. If you want it to reboot in an hour, type +60.

Type your password and your Mac will reboot at the time you designated.

Other Command Prompt Shutdown Switches and Parameters

The two methods we covered above are only two of the many ways you can shut down your Mac in Terminal. Below, we’ve included the complete list of shut down switches and descriptions from Apple.

Switch and Parameter Description
-h The system is halted at the specified time.
-k Kick everybody off.

The -k option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but super-users).

-n If the -o is specified, prevent the file system cache from being flushed by passing -n option to halt(8) or reboot(8).

This option should probably not be used.

-o If -h or -r is specified, shutdown will execute halt(8) or reboot(8) instead of sending a signal to launch(8).
-r The system is rebooted at the specified time.
-s The system is put to sleep at the specified time.
-u The system is halted up until the point of removing system power, but waits before removing power for 5 minutes so that an external UPS (uninterruptible power supply) can forcibly remove power.

This simulates a dirty shutdown to permit a later automatic power on. OS X uses this mode automatically with supported UPSs in emergency shutdowns.

time time is the time at which shutdown will bring the system down and may be the word now (indicating an immediate shutdown) or specify a future time in one of two formats: +number, or yymmddhhmm, where the year, month, and day may be defaulted to the current system values. The first form brings the system down in number minutes and the second at the absolute time specified.
warning message Any other arguments comprise the warning message that is broadcast to users currently logged into the system.
Marshall Gunnell
Marshall Gunnell is a writer with experience in the data storage industry. He worked at Synology, and most recently as CMO and technical staff writer at StorageReview. He's currently an API/Software Technical Writer at LINE Corporation in Tokyo, Japan, runs ITEnterpriser, a data-storage and cybersecurity-focused online media, and plays with development, with his RAID calculator being his first public project.
Read Full Bio »

The above article may contain affiliate links, which help support How-To Geek.