linux - 如何正确地关机

sudo sync 关机前数据同步写入磁盘, 一般情况下,关机命令会调用此命令将内存数据写入硬盘进行数据同步。

1. shutdown

# 现在立刻关机
- shutdown -h now

# 10分钟后自动关机
- shutdown -h +10

# 取消将要进行的关机
- shutdown -c

# 系统在今天的20:30分关机
- shutdown -h 20:30

# 立刻重启系统
- shutdown -r now

# 系统30分钟后重启,并将消息发送给在线用户
- shutdown -r +30 'the system will reboot'

# 仅仅发送警告信息,并不真正关机
- shutdown -k now 'the system will reboot'

2. poweroff

poweroff 会发送一个 ACPI 信号来通知系统关机。

- poweroff           ### 关闭机器
- poweroff --halt    ### 停止机器
- poweroff --reboot  ### 重启机器

3. halt

halt 通知硬件来停止所有的 CPU 功能,但是仍然保持通电。你可以用它使系统处于低层维护状态。

- halt             ### 停止机器
- halt -p          ### 关闭机器
- halt --reboot    ### 重启机器

4. reboot

reboot 通知系统重启。

- reboot           ### 重启机器
- reboot --halt    ### 停止机器
- reboot -p        ### 关闭机器

5. init

init 0

posted @ 2023-12-06 18:17  箫笛  阅读(762)  评论(0)    收藏  举报