Blog

Thoughts from my daily grind

How To Shutodwn Sleep and Restart Your Mac

Posted by Ziyan Junaideen |Published: 10 March 2021 |Category: Computers
Default Upload |

I switched to a 2019 27" iMac from Ubuntu a year and a half ago. Every thing looked polished. There were some things I missed, but the extended selection of professional grade software in a Linux/Unix like environment was worth-it. One of the first things I had to learn was how to shutdown and restart my Mac.

Here are ways you can shutdown / halt, restart or sleep your MacPro, iMac, MacBook Pro and MacMini.

GUI

The obvious choice is to use Apple (system) menu in the top left and choose the appropriate action either "Sleep", "Restart..." or "Shutdown..". Its simple enough. But if you are a geek like me, perhaps writing software in VIM, you will prefer to use the Terminal / iTerm.

Sleep using Terminal

Assume you want to sleep your computer in 60minutes. I have to do this especially if I am going out for lunch and some compute happening in the background and don't want to shutdown. The command that will come handy is shutdown with the option -s for sleep. Instead of using a time value you can use now to immediately execute the command.

=> sudo shutdown -s 15
=> sudo shutdown -s now

Here I instruct my Mac to go to sleep in 15minutes.

Shutdown using Terminal

Now assume that you need to halt the computer. Meaning power it off like in the end of the day. This uses the same shutdown command but with the h terminal command option. For example if you want to halt / shutdown your computer in 30 minutes you will use. You can halt the computer immediately using the now option.

Halting means you have a good chance of loosing unsaved work.

=> sudo shutdown -h 30
=> sudo shutdown -h now

Restart using Terminal

In the case you ever need to restart your Mac, you can easily do it using the shutdown command using the -r option that stands for restart.

=> sudo shutdown -r 30
=> sudo shutdown -r now

The first command will restart your Mac in 30 minutes. The second will restart the computer immediately.

No SUDO Access

The execute the shutdown command, your username should be added to the sudoers file. This has to be done by an admin user using sudo.

=> sudo visudo /private/etc/sudoers

Then add a record as follows (assuming your username is johndoe)

johndoe ALL=(ALL) ALL

Summary

You can easily shutdown/halt, restart and sleep your Mac using the GUI. Many developers work with the terminal. They may find using the terminal instead of the GUI more convenient. How ever rare, there are times the GUI goes unresponsive and then the terminal comes handy. It is always good to have familiarize the terminal.

Tags
About the Author

Ziyan Junaideen -

Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.

Comments