Linux-Beginners Series—Part 4_System Operation Related Commands

Previous: Linux-Beginner Series——Part 3_Getting help on the operation interface

1. Shutdown restart logout command

1. Restart or shutdown command -shutdown

Shutdown and restart the Linux system command shutdown, the system will notify all login users before shutdown and restart, and all new users will not be able to log in when the system is about to shut down and restart

Grammar format:
shutdown [OPTION]... TIME [MESSAGE]
shutdown   [选项]     时间    消息
Common parameters:
serial number parameter options Function Description
1 -r Restart the system instead of shutting it down. This parameter is commonly used when the system restarts
2 -h Shut down the system, this parameter is commonly used when the system is shut down
3 -c Cancel the shutdown command being executed
01 Specify how often to shut down/restart the system
// 关闭主机系统
[root@bogon ~]# shutdown -h 10
Shutdown scheduled for 五 2023-04-14 16:22:21 CST, use 'shutdown -c' to cancel.
[root@bogon ~]# 
Broadcast message from root@bogon (Fri 2023-04-14 16:12:21 CST):

The system is going down for power-off at Fri 2023-04-14 16:22:21 CST!

insert image description here

// 重启主机系统
[root@bogon ~]# shutdown -r 10
Shutdown scheduled for 五 2023-04-14 16:27:55 CST, use 'shutdown -c' to cancel.
[root@bogon ~]# 
Broadcast message from root@bogon (Fri 2023-04-14 16:17:55 CST):

The system is going down for reboot at Fri 2023-04-14 16:27:55 CST!

insert image description here

02 Shut down/restart the system at a specified time
// 关闭主机系统
[root@bogon ~]# shutdown -h 23:00
Shutdown scheduled for 五 2023-04-14 23:00:00 CST, use 'shutdown -c' to cancel.

// 重启主机系统
[root@bogon ~]# shutdown -r 23:00
Shutdown scheduled for 五 2023-04-14 23:00:00 CST, use 'shutdown -c' to cancel.
03 Realize immediate shutdown/restart of the system
// 关闭主机系统
// 两种方式:0/now
[root@bogon ~]# shutdown -h 0
[root@bogon ~]# shutdown -h now

// 重启主机系统
[root@bogon ~]# shutdown -r 0
[root@bogon ~]# shutdown -r now
04 Cancel shutdown/reboot system plan
// 取消关闭主机计划 / 取消重启主机计划
[root@bogon ~]# shutdown -c
Broadcast message from root@bogon (Fri 2023-04-14 16:23:17 CST):
The system shutdown has been cancelled at Fri 2023-04-14 16:24:17 CST!

注意:上述操作实操过程中必须使用系统管理员用户(root)进行操作。

2. Restart or shutdown command -halt/poweroff/reboot/systemctl

The four commands halt/poweroff/reboot/systemctl also have corresponding shutdown and restart functions.

Grammar format:
halt [option]
poweroff [option]
reboot [option]
systemctl [option]
01 Use the halt command to shut down
[root@bogon ~]# halt
02 Use the poweroff command to shut down
[root@bogon ~]# poweroff
03 Use the reboot command to restart
[root@bogon ~]# reboot
04 Use the systemctl command to restart/shut down the host
// 关闭主机系统
[root@bogon ~]# systemctl poweroff

// 重启主机系统
[root@bogon ~]# systemctl reboot

3. Logout exit system command

Linux multi-user management system

// 注销退出当前用户窗口
[root@bogon ~]# logout

// 注销退出当前用户窗口,等价于使用快捷键ctrl+d
[root@bogon ~]# exit

Guess you like

Origin blog.csdn.net/m0_62181310/article/details/130170809