Linux正确的关机方法
观察系统的使用状态
who 看目前有谁在线;
netstat -a 查看网络联机状态;
ps -aux 查看后天执行的程序;
关机之前先将数据同步写入硬盘: sync
su - 切换到root身份;
-
shutdown 关机
shutdown -k/r/h/c
shutdown -h [时间] (now相当于时间为0),将系统的服务停掉之后,立刻关机;
shutdown -k [时间] 不要真的关机,只是发送警告信息出去。
shutdown -r 在系统的服务停掉之后重新启动;
shutdown -c 取消已经在进行的shutdown命令内容
新版本的linux,后面不一定要加时间,不加时间,默认以1分钟为限。 -
reboot 重启
-
halt 关机, 系统停止,屏幕可能会保留系统已经停止的信息;
-
poweroff 关机, 系统关机,没有提供额外的店里,屏幕空白;
sync; sync; sync; reboot
halt、poweroff、reboot、shutdown等实际上都是调用 systemctl命令