Use Terminal Commands to Shut Down a Mac Computer

Mac tips how to use the terminal to shut down the Mac computer, come and learn from the macw editor!

Shut down your Mac via Terminal

First, you must first open a terminal.
insert image description here
With Terminal open, you can shut down your Mac. You will use the "sudo" command here; otherwise, you will get the error message shown below.
insert image description here
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. Type now if you want to do this right away. If you want it to close within an hour, type +60.

Press Enter and enter your password when prompted.
insert image description here
Your Mac will now shut down at the time you specified.

Restart the Mac via Terminal

The restart process in Terminal is the same as shutdown, except for one small change. Start by opening a terminal.

When the terminal opens, type sudo shutdown -r <time>. Also, you must use the sudo (superuser do) command to gain access to superuser privileges, or you will get a "not superuser" error message.
insert image description here
Replace <time> with the specific time you want your Mac to restart. If you replace <time> with now, it will start restarting immediately. Type +60 if you want it to restart within an hour.

Enter your password, and your Mac will restart at the time you specify.

Additional Command Prompt shutdown switches and parameters

The two methods we've covered above are just two of the many ways you can shut down your Mac in Terminal. Below, we've covered Apple's complete list and descriptions of the shutdown switches. Everyone can learn from it.
insert image description here

Guess you like

Origin blog.csdn.net/snowpiaopiao/article/details/128316337