在 Linux 系统中,有几种常用的命令可以用来关机。以下是几种常见的方法:
shutdown
命令:shutdown -h now
:立即关机。shutdown -h +1
:一分钟后关机。shutdown -h +15 "System will shutdown for maintenance"
:15 分钟后关机,并显示一条消息。shutdown -h hh:mm
:在指定的时间(24 小时格式)关机,例如shutdown -h 23:00
。
poweroff
命令:poweroff
:立即关机,效果类似于shutdown -h now
。
halt
命令:halt
:停止系统,但不一定切断电源(取决于系统的硬件和配置)。halt --poweroff
:确保系统完全关闭电源。
init
命令:init 0
:将系统切换到运行级别 0,通常表示关机。
systemctl
命令(适用于使用 systemd 的系统):systemctl poweroff
:立即关机。systemctl halt
:停止系统,但不一定切断电源。
这些命令通常需要超级用户权限(root 权限)才能执行。因此,你通常需要在命令前加上 sudo
,例如 sudo shutdown -h now
。
请确保在关机前保存所有未保存的工作,并通知所有正在使用系统的用户,以免丢失数据或造成不便。