用 shutdown 命令在终端重启或关闭 Mac

用 macOS 自带的 shutdown 命令重启或关机——菜单栏无响应或远程连接时特别好用。

macOS终端电源与睡眠中风险
运行 sudo shutdown -r now 立即重启,或运行 sudo shutdown -h now 直接关机。

01命令

命令
$ sudo shutdown -r now

02作用说明

shutdown 是苹果自带的、用于安全停止或重启系统的命令:-r 表示重启,-h 表示关机断电,时间参数可以是 now(立即),也可以是未来的某个时间。相比直接断电,正常关机会让应用和系统保存状态,各个程序能优雅退出。它在 SSH 和屏幕共享下同样可用,是远程 Mac 界面卡死时的首选处理办法。

03风险

风险中风险
使用条件Requires administrator (sudo) privileges.
!注意: 关机时打开的应用可能被强制退出,未保存的内容会丢失;注意区分参数:-r 是重启,-h 是彻底关机。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • SHUTDOWN(8) - macOS manual page
    Apple (Xcode man pages mirror) · vendor-doc · 2026-09-17
    依据: The manual page contains 'shutdown -r' for rebooting and explains the time argument can be the word 'now' or a future time in yymmddhhmm format.
  • shutdown - Shut down or restart the system
    SS64 · technical · 2026-09-17
    依据: Documents the shutdown syntax including '-r Reboot the system' and '-h Halt or power off', with time arguments such as 'now'.

最后验证: 2026-09-19 · 分类: 系统与设置

06相关方案