macos,

How to shutdown and restart MacOS from the Terminal

Nov 29, 2021 · 1 min read · Post a comment
How to shutdown and restart MacOS from the Terminal

As a DevOps engineers, we must get used to running commands from the terminal. Let’s see how easy and fast we can shutdown and restart a MacOS machine after long day of work.

Prerequisites

  • MacOS shell environment

Solutions

Shutdown a MacOS machine

Open a terminal and run the following command:

sudo shutdown -h now 

or, if you want to shut it down after 15 minutes, use the following command instead:

sudo shutdown -h +15

Restart a MacOS machine

Open a terminal and run the following command:

sudo shutdown -r now

You could add minutes or hours when restarting the machine too. For instance:

sudo shutdown -r +60

Conclusion

TL;DR a single command shutdown that takes parameters: -h for shutdown, -r for restart and -s for sleep. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on telegram.