قالب وردپرس درنا توس
Home / Tips and Tricks / How to close your Mac with Terminal

How to close your Mac with Terminal



  A MacBook Pro open on a table next to a mug and a vase of flowers.
Krisda / Shutterstock

Closing your Mac in Terminal gives you more options and flexibility than using the exit option in the Apple menu or the power button. This is how you do it!

Shut down your Mac via Terminal

First you have to open Terminal (or an alternative that you normally use). Press Command + Space to open Spotlight Search, type "terminal" and then select it from the search results.

RELATED: What to do if your Mac does not shut down [1

9659006]   Type

With the terminal open, you can shut down your Mac. You use the "sudo" command here; otherwise you will be greeted by the error message below.

RELATED: How to manage sudo access on Linux

  The

The sudo (superuser do) command, gives you superuser security rights by default.

Type the following command to close your Mac:

sudo shutdown -h

Replace with the specific time you want to turn off your Mac. If you want to do this immediately, type now . If you want it to close within an hour, type +60 .

Press enter and type your password when prompted.

 Enter your password when prompted in the terminal.

Your Mac will now shut down at the time you specified.

Restart your Mac via Terminal

Apart from a small change, the restart process in Terminal is identical to closing. Press Command + Space to open Spotlight Search and search for Terminal.

RELATED: The best "Just For Fun" tricks hidden in the macOS terminal

Type when Terminal opens sudo shutdown -r . Again, you must use the command sudo (superuser do) to access the rights of the superuser, otherwise you will get the error message & # 39; not super user & # 39 ;.

<img class = "alignnone wp-image -513356 size-full" data-pagespeed-lazy-src = "https://www.howtogeek.com/wp-content/uploads/2020/01/xreboot-command .png.pagespeed.gp + jp + jw + pj + ws + js + rj + rp + rw + ri + cp + md.ic.9qcljVNWBh.png "alt =" The command "sudo shutdown -r

Replace

with the specific time at which your Mac must be restarted. If you now replace with you will immediately be restarted. If you want it to restart within an hour, type +60 .

Enter your password and your Mac will be restarted at the time you specify.

Other Command Prompt Switches and Parameters

The two methods we discussed above are just two of the many ways you can shut down your Mac in Terminal. Below we have included the complete list of shut-off switches and descriptions from Apple.

Switch and parameter Description
-h The system is stopped at the specified time.
-k Kick everyone off.

The -k option does not stop the system, but leaves the system disabled for multiple users with logins (for all users except super users).

-n If the -o is specified, prevent the file system cache from being emptied by stopping the -n option to stop (8) or restart (8).

This option should probably not be used.

-o If -h or -r is specified, stop (8) or restart (8) is executed on shutdown instead of sending a signal to start (8).
-r The system will be restarted at the specified time.
-s The system is put to sleep at the specified time.
-u The system is stopped until the system power is turned off, but wait 5 minutes before the power is turned off so that an external UPS (uninterruptible power supply) can forcefully remove the power.

This simulates a dirty shutdown to turn on automatically later. OS X uses this mode automatically with supported UPS & # 39; and in emergency stops.

time time is the time when shutdown shuts down the system and can now be the word (indicates an immediate shutdown) or specify a future time one of two formats: + number or yymmddhhmm where the year, month and day can be set to the current system values ​​by default. The first form lowers the system in number minutes and the second at the specified absolute time.
warning message All other arguments include the warning message that is sent to users who are currently logged into the system.


Source link