How to shut down your Mac using Terminal

Contents

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

If you turn off your Mac in Terminal, You get more options and flexibility than using the shutdown option in the Apple menu or the power button. This is how you do it!

Shut down your Mac via terminal

First, should open Terminal (or any alternative you use regularly). Press Command + Space to open Spotlight Search, scribe “terminal” and then select it in the search results.

RELATED: What to do when your Mac won't turn off

Writes "terminal" in the Spotlight search bar and then click on it in the results.

With the terminal open, you are ready to shut down your Mac. You will use the command “sudo” here; opposite case, the error message shown below will appear.

RELATED: How to control access to sudo on Linux

the sudo The command (superuser do), by default, grants 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 it immediately, scribe now. If you want it to turn off in an hour, scribe +60.

Press enter and type your password when prompted.

Enter your password when prompted in the terminal.

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

Restart your Mac via terminal

Apart from a little change, the restart procedure in Terminal is identical to shutdown. Press Command + Space to open Spotlight Search and find Terminal.

RELATED: The best tricks “just for fun” hidden in macOS terminal

When Terminal opens, scribe sudo shutdown -r <time>. Again, must use the sudo (superuser do) to enter superuser privileges, or you will get the error message “not superuser”.

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

Enter your password and your Mac will restart at the time you have designated.

Other Command Prompt Shutdown Switches and Parameters

The two methods we previously covered are just two of the many ways you can shut down your Mac in Terminal.. Next, We have included the complete list of kill switches and descriptions of Apple.

Switch and parameter Description
-h The system stops at the specified time.
-k Kick everyone out.

The -k option does not truly stop the system, but it leaves the multi-user system with the logins disabled (for everyone except super users).

-North If -o is specified, prevent the filesystem cache from being flushed by passing the -n option to stop (8) the restart (8).

This option should probably not be used.

-O Yes if it specifies -h or -r, shutdown will halt (8) or will restart (8) instead of sending a signal to start (8).
-r The system reboots at the specified time.
-s The system goes to sleep at the specified time.
-u The system stops to the point of disconnecting power from the system, but wait before turning off the power for 5 minutes for an external UPS (Uninterruptible Power Supply) can forcibly disconnect the power.

This simulates a dirty shutdown to allow for a later automatic start-up. OS X uses this mode automatically with compatible UPSs in emergency shutdowns.

weather weather it is the moment when the shutdown will cause the system to shut down and may be the word now (indicating an immediate shutdown) or specify a future time in one of two formats: + number, O aammddhhmm, where the year, month and day can be determined by default in current system values. The first way lowers the system in number minutes and the second at the specified absolute time.
warning message Any other argument includes the warning message that is transmitted to users today connected to the system.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.