+5 votes
856 views
Command to restart or shut down Mac terminal

in Mac by (551k points)
reopened | 856 views

1 Answer

+3 votes
Best answer

1. How to restart macOS through commands
2. How to restart macOS with the active FileVault function
3 How to restart macOS graphically from the Apple menu
4. How to program the restart of macOS graphically
5. How to restart Mojave macOS using the computer's shutdown button
6. How to turn off macOS through the terminal
7. How to program macOS shutdown through the terminal
8. How to turn off macOS graphically through the Apple menu
9. How to program the shutdown of macOS
10. How to turn off macOS through the computer's shutdown button

macOS Mojave is the latest version that Apple has released at the operating system level for its millions of users and is integrated with numerous features such as:

  • A new dynamic desktop .
  • Integration of the dark mode .
  • New tools for screen or window cuts .
  • Continuous camera.
  • Improvements in the Finder.
  • New functions of stacking elements and many more.

Although these features are attractive to us, but there are certain tasks that will remain elementary in the daily use of Mojave macOS which will hardly be replaced and these are the restart and shutdown of the operating system. The point that TechnoWikis wants you to understand is that there are different methods to execute these actions and for that reason we will explain each of them in detail and so you can select the one that best suits your needs..

Note
Although we speak of Mojave macOS, these methods apply equally to other versions such as High Sierra, Sierra, El Capitán, etc.

To restart our operating system we have both graphic and command line forms.

To stay up to date, remember to subscribe to our YouTube channel! SUBSCRIBE


1. How to restart macOS through commands

Step 1

The first point to keep in mind is that to access the terminal we have the following options:
  • On the route Go / Utilities / Terminal
  • Using the key combination ⇧ + ⌘ + U
  • Through Spotlight

There we will have some reset options, these are:

If we want to immediately restart the system we must execute the following order..

 sudo reboot 
When pressing Enter we will enter our password and the system will be automatically restarted:

image

Step 2

Through the terminal we can execute a series of AppleScript which invoke the actions of standard restart of macOS. It is similar to pressing the Restart option in the Apple menu. To restart the system using this method we will execute the following:
 osascript -e 'tell application "System Events" to restart 
There we simply press "Enter" and immediately the system will be restarted:

image

Step 3

Once the system has been restarted, the terminal will automatically open where we will see the following. There we verified that the session has been restored correctly.

image


2. How to restart macOS with the active FileVault function


Maybe you wonder, what is FileVault ?, well, FileVault has been integrated into macOS as an encryption system which is based on the 128-bit Advanced Encryption Standard AES encryption method for the whole data protection topic of the system.

In case of having active FileVault and trying the remote restart, an error will be given, in order to overcome this and achieve the restart, we must execute the following:

 sudo fdesetup authrestart 

image

There we press Enter and this will prevent unlocking FileVault.


3 How to restart macOS graphically from the Apple menu


It is perhaps the most used method by all of us since it gives access to the safest way to restart our equipment and the fundamental reason is that through this process we can store our documents and configurations without being accidentally closed losing their content.
Step 1

To use this method, just click on the Apple logo located in the upper left corner and in the expanded menu select "Restart":

image

Step 2

When clicking on this option, the following pop-up window will be displayed:

image

Functional tasks
There we can notice two functional tasks that are:
  • Automatic restart in a minute in case we do not click on the Restart button again.
  • Activation of the "Reopen the windows when restarting the session" box, which allows us to open all the windows in which we are currently working.

We can define what action to do and click on "Restart" to proceed with the reboot of the system..


4. How to program the restart of macOS graphically


One of the built-in functions of macOS is the ability to program the restart of the system at a specific time automatically. This will be useful to avoid carrying out manually according to the days that are necessary.
Step 1

To carry out this programming action, click on "System Preferences" which is located in the Dock and the following will be displayed. There we will select the category "Energy saving" image
Step 2

In the new window displayed, click on the "Schedule" button located in the lower right corner:

image

Step 3

A pop-up window will be displayed where we will define the "Restart" action and define the frequency with options such as:
  • Everyday
  • Specific days
Next we select the time in which the automatic reboot of the system will be programmed. Press Ok to complete the task and the macOS system will restart as scheduled.

image


5. How to restart Mojave macOS using the computer's shutdown button


Another one of the graphical methods to restart macOS is using the own button of shutdown of the equipment which we found in the first row in the last position of left to right. For this we must press the Ctrl key and press said button and the following window will be displayed where we will click on "Restart":

image

As we saw earlier, we can allow all active windows to be opened again.

We have learned the different methods to restart our macOS, now we will see how to turn off the system graphically and through the terminal.


6. How to turn off macOS through the terminal


Recall the various methods already described above to access the terminal, once there are varied options to turn off the system.
Step 1

To turn off the system immediately we will execute the following line:
 sudo shutdown -h now 
There we will enter our password and macOS will shut down immediately:

image

Note
Another command with which you will automatically turn off macOS is with the halt command, for this you just need to use the following line:
 sudo halt 
Step 2

Now, macOS allows us to program the shutdown in a period of time which is measured in minutes, for example, if we want to turn off the computer in 45 minutes we will execute the following:
 sudo shutdown -h +45 
We enter our password and we will see the action to execute as well as the respective time:

image

Step 3

To turn off the system through the terminal as if it were done from the Apple menu, we will use the AppleScript as follows:
 osascript -e 'tell application "System Events" to shut down " 

image

When pressing the Enter key the shutdown will be immediate.


7. How to program macOS shutdown through the terminal


If we want to program the shutdown of macOS from the terminal it will be possible thanks to the command "pmset" which has the task of managing the power options. So if we want to turn off the system on April 29 at midnight we will execute the following:
 sudo pmset schedule shutdown "04/29/19 00:00:00" 

image

This works on a particular day, if we want it to be every day we must execute the following line:

 sudo pmset repeat shutdown MTWRFSU 00:00:00 

8. How to turn off macOS graphically through the Apple menu

Step 1

As we saw in the reboot process, the most used way to turn off macOS is from the Apple logo located in the upper left corner, when clicking on this Apple logo we will select "Shut down":

image

Step 2

The following window will be displayed where we confirm the action by pressing again on Shutdown and it will be possible that the next time the equipment is turned on. In order to load the windows that are open at that moment, we activate the "Reopen windows when restarting session" box:

image


9. How to program the shutdown of macOS

Step 1

It is a method that will help us to automatically turn off the system without our participating there. As we saw in the restart, for this we go to "System Preferences / Energy Saving" and in the bottom of the window displayed we click on the "Schedule" button:

image

Step 2

In the pop-up window we select the option "Turn off computer" and then we define which days to perform this action (or we can select All days) as well as the time in which the equipment will be shut down:

image

Press Ok to confirm the task and in this way macOS will turn off as we configure it.


10. How to turn off macOS through the computer's shutdown button

Option 1
It is a method that can be used in two different ways, the first of which is to press the off button of the computer for 5 seconds and the computer will turn off completely but this will cause everything that has not been saved to be lost.
Option 2
The second option is to press the Ctrl key and the power off button and the following will be displayed:

image

There we will be able to recover the open windows as well as turn off the equipment in a securely closed manner as the processes and services should be.

We are ready to restart or shut down macOS both graphically and through commands and each one of them has its respective usage and customization options.


by (3.5m points)
edited

Related questions

+4 votes
1 answer
+5 votes
1 answer
+4 votes
1 answer
+5 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users