Shutdown Mac Command Line

Shutting Down a Mac from Command Line with ‘shutdown’

This Command Line trick allows you to specify normal Shutdown/Restart or if you want to Force Shutdown/Restart and also allows you to specify the time to wait before Force Shutdown/Restart. Shutdown.exe is the process responsible for System Shutdown and Restart. Normal Shutdown is the term we’ve used here to mention the default Shutdown. The ‘Kill’ Command in Terminal. If you prefer a command line method for dealing with unresponsive apps, you can use the ‘kill’ command in Terminal. To use this method, you’ll need to determine the app’s Process ID (PID), a numeric value that OS X uses to keep track of each unique application. Sep 04, 2017 To shutdown Mac from terminal follow the steps given below: 1. Open the Terminal on you Mac OS device. Enter the following syntax command below: sudo shutdown -h now 3. When you are done, you can simply hit the return key and then authenticate the command using an administrative. At shutdown time a message is written in the system log, containing the time of shutdown, who initiated the shutdown and the reason. A terminate signal is then sent to launchd to bring the system down to single-user state (depending on above options). A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM should suffice).

Shutdown Mac Command Line Command

Apt for the name, the ‘shutdown’ command can shutdown a Mac as well as reboot a Mac via Terminal. To turn off a Mac with the shutdown command, you will use the -h flag and give the time for ‘now’ making the syntax like so:

sudo shutdown -h now

As soon as you hit return and authenticate the command, the Mac halts and kills all applications and processes and shuts the computer down. There is no warning and no dialog, it happens instantly.

Unless you’re actively logged in as the root user (via single user or otherwise), you will need to prefix the shutdown command with ‘sudo’ to give the command superuser privileges, thus requiring an administrative password.

If you feel like trying this yourself (and you have all data saved and nothing important open) do the following:

Shutdown Mac Command Line
    1. Open the Terminal in Mac OS (found in /Applications/Utilities/ folder)
    2. Enter the following command syntax exactly:

sudo shutdown -h now

  1. Hit the return key and authenticate with an administrative password to immediately shut down the Mac

Shutdown Mac Command Line List

The Mac will immediately shut down. No data is saved and no dialogs are confirmed, the shut down happens instantly.

You can also use the -h flag to set a time or date for shutting down the computer, for example in 30 minutes, but if you want to shut down the Mac instantly you would use the ‘now’ parameter with the -h flag rather than a number.

Shutting down a Mac in XX Minutes from the Command Line

If you do feel like putting a delay on the shutdown, you can use the following command syntax instead:

sudo shutdown -h +30

Replace “30” with any other number of minutes to shut down the Mac in that amount of time. For example if you put “2” instead of 30 then you would shut down the Mac in 2 minutes.

Shutting Down a Mac via Terminal with ‘halt’

The ‘halt’ command can also instantly shut down a Mac via the command line. The process and syntax for ‘halt’ to turn off a Mac is as follows:

    1. Open the Terminal .app in Mac OS
    2. Enter the halt command syntax exactly as described:

sudo halt

  1. Hit the return key, authenticate with sudo to instantly shut down the Mac

Whether you use ‘halt’ or ‘shutdown’ does not matter really, it’s mostly preference and what you can remember when necessary.

By the way, the shutdown command can also be also be used to restart a Mac from the command line by using the -r flag instead of the -h flag.

Shutdown Mac Command Line

Shutdown Mac Command Line Commands

Keep in mind that for most users the command line approach is not going to be better or faster than accessing the  Apple menu Shut Down option or using the power button keyboard shortcuts, this is really aimed at advanced users who are already at the command line anyway.