![mac关闭终端命令](https://i-blog.csdnimg.cn/blog_migrate/fa80674a7ffa56d4bd84327fc3dad416.png)
mac关闭终端命令
![A MacBook Pro open on a table next to a mug and a vase of flowers.](https://i-blog.csdnimg.cn/blog_migrate/1492e579702f7ac2c70ed4b6139c611d.png)
If you shut down your Mac in Terminal, you get more options and flexibility than using the shutdown option in the Apple menu or the power button. Here’s how you do it!
如果在终端机中关闭Mac,则与使用Apple菜单或电源按钮中的关闭选项相比,您将获得更多的选择和灵活性。 这是您的操作方式!
通过终端关闭Mac (Shut Down Your Mac via Terminal)
First, you have to open Terminal (or any alternative you normally use). Press Command+Space to open Spotlight Search, type “terminal,” and then select it from the search results.
首先,您必须打开终端(或您通常使用的任何替代方法)。 按Command + Space打开Spotlight搜索,键入“终端”,然后从搜索结果中选择它。
![Type "terminal" in the Spotlight search bar, and then click it in the results.](https://i-blog.csdnimg.cn/blog_migrate/a3565ce28335cd8dd88b6b7853b20bc2.png)
With terminal open, you’re ready to shut down your Mac. You’ll use the “sudo” command here; otherwise, you’ll be greeted by the error message shown below.
打开终端后,您就可以关闭Mac了。 您将在此处使用“ sudo”命令 ; 否则,您会受到以下显示的错误消息的欢迎。
![The "NOT super-user" error message in a terminal window.](https://i-blog.csdnimg.cn/blog_migrate/074d26846d35f39de7831d4a53b7eff6.png)
The sudo
(superuser do) command, by default, gives you superuser security privileges.
缺省情况下, sudo
(superuser do)命令为您提供超级用户安全特权。
To shut down your Mac, type the following command:
要关闭Mac,请键入以下命令:
sudo shutdown -h <time>
sudo shutdown -h <time>
Replace <time>
with the specific time you want to shut down your Mac. If you want to do so immediately, type now
. If you want it to shut down in an hour, type +60
.
将<time>
替换为您要关闭Mac的特定时间。 如果你想立即这样做,键入now
。 如果要在一小时内关闭,请输入+60
。
Press enter and type your password when prompted.
按Enter并在出现提示时输入密码。
![Type your password when prompted in terminal.](https://i-blog.csdnimg.cn/blog_migrate/3ab4aa973589ad73d9380edbf426ee37.png)
Your Mac will now shut down at the time you specified.
通过终端重启Mac (Restart Your Mac via Terminal)
Aside from one small change, the restart process in Terminal is identical to shutting down. Press Command+Space to open Spotlight Search and search for Terminal.
除了一个小的更改,Terminal中的重新启动过程与关闭相同。 按Command + Space打开Spotlight搜索并搜索终端。
When Terminal opens, type sudo shutdown -r <time>
. Again, you must use the sudo
(superuser do) command to access superuser privileges, or you’ll get the “not super-user” error message.
终端打开时,键入sudo shutdown -r <time>
。 同样,您必须使用sudo
(超级用户执行)命令来访问超级用户特权,否则您将收到“非超级用户”错误消息。
![The "sudo shutdown -r <time>" command in a terminal window.](https://i-blog.csdnimg.cn/blog_migrate/dda6d0e35ad001fb4a0c74d4a2b6b45a.png)
Replace <time>
with the specific time you want your Mac to restart. If you replace <time>
with now
, it initiates an immediate reboot. If you want it to reboot in an hour, type +60
.
将<time>
替换为您要Mac重新启动的特定时间。 如果将<time>
替换为now
,它将启动立即重启。 如果要在一小时内重新启动,请输入+60
。
Type your password and your Mac will reboot at the time you designated.
输入密码,您的Mac将在您指定的时间重新启动。
其他命令提示符关闭开关和参数 (Other Command Prompt Shutdown Switches and Parameters)
The two methods we covered above are only two of the many ways you can shut down your Mac in Terminal. Below, we’ve included the complete list of shut down switches and descriptions from Apple.
我们上面介绍的两种方法只是在终端机中关闭Mac的众多方法中的两种。 下面,我们提供了Apple关机开关的完整列表和说明。
Switch and Parameter | Description |
-h | The system is halted at the specified time. |
-k | Kick everybody off. The -k option does not actually halt the system, but leaves the system multi-user with logins disabled (for all but super-users). |
-n | If the -o is specified, prevent the file system cache from being flushed by passing -n option to halt(8) or reboot(8). This option should probably not be used. |
-o | If -h or -r is specified, shutdown will execute halt(8) or reboot(8) instead of sending a signal to launch(8). |
-r | The system is rebooted at the specified time. |
-s | The system is put to sleep at the specified time. |
-u | The system is halted up until the point of removing system power, but waits before removing power for 5 minutes so that an external UPS (uninterruptible power supply) can forcibly remove power. This simulates a dirty shutdown to permit a later automatic power on. OS X uses this mode automatically with supported UPSs in emergency shutdowns. |
time | time is the time at which shutdown will bring the system down and may be the word now (indicating an immediate shutdown) or specify a future time in one of two formats: +number, or yymmddhhmm, where the year, month, and day may be defaulted to the current system values. The first form brings the system down in number minutes and the second at the absolute time specified. |
warning message | Any other arguments comprise the warning message that is broadcast to users currently logged into the system. |
开关和参数 | 描述 |
-H | 系统在指定时间停止。 |
-k | 踢开所有人。 -k选项实际上并没有停止系统,而是使系统多用户禁用了登录名(超级用户除外)。 |
-n | 如果指定了-o,则通过将-n选项传递给halt(8)或reboot(8)来防止刷新文件系统缓存。 可能不应该使用此选项。 |
-o | 如果指定了-h或-r,则shutdown将执行halt(8)或reboot(8),而不是发送信号至launch(8)。 |
-r | 系统将在指定的时间重新引导。 |
-s | 系统在指定时间进入睡眠状态。 |
-u | 系统将停止运行,直到断电为止,但是要等5分钟再断电,以便外部UPS(不间断电源)可以强制断电。 这将模拟脏关机,以允许以后自动开机。 在紧急关机时,OS X会与支持的UPS自动使用此模式。 |
时间 | time是关机将使系统停机的时间,并且可以是now (表示立即关机)或以两种格式之一指定未来时间: + number或yymmddhhmm ,其中年,月和日可以默认为当前系统值。 第一种形式带来的分钟数的系统停机和第二在指定绝对时间。 |
警告信息 | 任何其他自变量都包含警告消息,该警告消息广播给当前登录到系统的用户。 |
翻译自: https://www.howtogeek.com/512304/how-to-shut-down-your-mac-using-terminal/
mac关闭终端命令