

In the screenshot below, I set mine to turn off in 500 minutes. In the Terminal app on your Mac, enter the following command: sudo shutdown -r now Restart a remote computer immediately In the Terminal app on your Mac, enter the following commands: ssh -l admincomputer sudo shutdown -r now Replace admin with the short name of a user account on the remote computer.
#Mac shutdown command code#
For example, the following code will shut down your Mac in 10 minutes. If your Mac is not completely frozen, close any open apps before you force. You can customize this command a little further. For example, to use Command-C (copy), press and hold the Command key, then the C key, then release both keys.

This will shut down your Mac as soon as you hit the enter button in Terminal to execute it. To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. Shutdown immediately sudo shutdown -h now You will be asked to enter your admin password. Open Terminal (you can open Applications > Utilities to find it), and depending on what you want to do, enter one of the following commands. If a glitching application isnt the reason, you should check for a crashing background process. You can do a shutdown immediately or schedule a shutdown: However, if you cant quit a program, press Option + Command + Esc - the equivalent of Ctrl-Alt-Delete on Mac, select the app, then click on Force Quit. There are different variations of the shutdown command that you can use to shut down your Mac in Terminal. Use the shutdown command in Terminal on Mac Ensure that you are ready (for example, save any unsaved changes in Pages) to turn off your Mac to ensure you do not experience any data loss. Before going further, I should note that some of the commands below will cause your Mac to turn off immediately without any warning or confirmation. Your Mac will reboot after several seconds. Furthermore, this can be used in special circumstances, like in Single-user Mode or Verbose Mode or in remote administration.Īlthough there are several ways to do this using the command line, we will cover the most used and practical ones. To force a restart, press and hold the Control + Command + Power keys simultaneously until your computer’s screen goes blank.
#Mac shutdown command how to#
This article is for users who want to know how to shut down their Mac from the command line. If your Mac is frozen and you can't save anything, take a photo of your work in progress on your phone so you can recreate it later. If possible, you may want to make a new Time Machine backup before restarting.

Of course, you may say there are many other, perhaps easier, ways to shut down a Mac, like clicking the Restart or Shut Down options in the Apple menu, using keyboard shortcuts or pushing the physical power button. Try to save each of your open files by pressing Cmd + S or selecting File > Save from the menu bar. You can run AppleScript from the command line by using osascript. You can ask macOS to shut down from the user's account by telling System Events using AppleScript. Sometimes turning off your Mac can be a great way to fix some of your issues. 1 Answer Sorted by: 11 Using pmset or any system tools to perform shutdown requires sudo. If you want to turn off your Mac using Terminal, I cover a variety of ways to do this.
