Quick Links

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

Spotlight search

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

NOT superuser message

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.

Enter shutdown password

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

Related: How to Turn Your Mac On and Off

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.

reboot command

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.