linux下正常关机命令有哪些
Linux下正常关机命令有哪些?
一般来说,Linux下关机命令有两种:一种是正常关机命令,另一种是强制关机命令。
正常关机命令是指让系统完成正常的关机过程,系统会自动执行一系列操作,包括卸载系统内核、关闭系统服务、关闭系统进程等,最后将系统关闭。
强制关机命令是指不管系统是否完成了正常的关机过程,直接将系统关闭。
下面介绍一下Linux下常用的正常关机命令:
1. shutdown命令
shutdown命令是一个用于关闭或重启系统的命令,它可以设置系统在指定时间后自动关机或重启。
语法:
shutdown [选项]... 时间 [警告信息]
选项:
-h:关机
-r:重启
-c:取消正在进行的关机或重启操作
时间:
关机或重启的时间,可以使用以下格式:
now:立即执行
+m:m分钟后执行
+h:h小时后执行
+d:d天后执行
警告信息:
系统在执行关机或重启操作前给出的警告信息。
使用方法:
1)立即执行关机操作
命令:
sudo shutdown -h now
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:31:33 ...
The system is going down for halt NOW!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
2)设置5分钟后执行关机操作
命令:
sudo shutdown -h +5
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:32:07 ...
The system is going down for halt in 5 minutes!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
3)设置10小时后执行重启操作
命令:
sudo shutdown -r +10
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:32:37 ...
The system is going down for reboot in 10 hours!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
2. poweroff命令
poweroff命令是一个用于关闭系统的命令,它可以设置系统在指定时间后自动关机。
语法:
poweroff [选项]... [警告信息]
选项:
-h:关机
-r:重启
-c:取消正在进行的关机或重启操作
警告信息:
系统在执行关机或重启操作前给出的警告信息。
使用方法:
1)立即执行关机操作
命令:
sudo poweroff
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:33:46 ...
The system is going down for halt NOW!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
2)设置5分钟后执行关机操作
命令:
sudo poweroff -h +5
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:34:16 ...
The system is going down for halt in 5 minutes!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
3)设置10小时后执行重启操作
命令:
sudo poweroff -r +10
输出:
Broadcast message from root@ubuntu (/dev/pts/0) at 16:34:46 ...
The system is going down for reboot in 10 hours!
Connection to 192.168.1.100 closed by remote host.
Connection to 192.168.1.100 closed.
相关文章