How to shut down Mac via command line

Advanced Mac users may need to shut down the computer through the command line. It may

Useful for remote control using SSH, in single-user mode and when problems arise with the operation and management of the system.

There are several ways to turn off your Mac through the command line, we will look at the two easiest.

Advertising

Advertising

The command line on the Mac offers many commands for performing various tasks and system functions, so you can also turn off the computer through it.

Important warning: disabling the Mac through the command line is instantaneous. A confirmation or warning window does not pop up, no time is given to save documents or close programs. The Mac immediately eliminates all active processes and shuts down instantly. This can lead to data loss, so you must prepare your computer for shutdown before using the command.

Disconnection Mac team "shutdown"

To disable a Mac using the shutdown command, use -h and specify the time now. The command will look like this:

Advertising

Advertising

sudo shutdown -h now

As soon as you press the return button, the Mac will close all programs and terminate all processes, and then shut down. There will be no warning dialogs, this will happen instantly.

If you are not registered as a root user, you will need to add “sudo” before the command so that it receives superuser privileges.

If you want to try this method (and you have everything saved and closed), follow the instructions:

  1. Open a command prompt (via / Applications / Utilities / folder)
  2. Enter the following command:

sudo shutdown -h now

3. Press the return button and enter the administrative password to turn off the Mac.

You can use “-h” to indicate the time and date the computer was turned off. For example, “in 30 minutes” (after 30 minutes), but if you want to immediately turn off the Mac, you need to enter “now”.

Disconnection Mac in a few minutes

If you want to turn off the computer later, you can enter the following command:

sudo shutdown -h +30

“30” can be replaced with any double-digit number, and the Mac will shut down after so many minutes. If you enter “2” instead of “30”, the computer will turn off after two minutes.

Disconnection Mac the team Halt

The halt command also shuts down the Mac instantly.

  1. Open Terminal.app.
  2. Enter the following command:

sudo halt

3. Press “return” and enter the password.

There is no difference in using “halt” or “shutdown”. Use a team that is easier for you to remember.

The shutdown command can also be used to reboot; for this, instead of -h, enter -r.

Ordinary users are better off turning off the computer through the Apple menu, so this method is suitable for those who regularly use the command line.