Linux self-study journey-basic commands (shutdown shutdown restart command)

Linux self-study journey-basic commands (shutdown)


Preface

1. In the previous section, we talked about the usage of the tar command to pack and compress. If you haven't read it yet, you can click below to watch: tar

2. In this section, we will talk about shutdown and restart commands


Tip: The following is the content of this article

1. What can shutdown do?

Shutdown, restart, and delayed shutdown can all be done.

Two, shutdown use

  • Command name: shutdown
  • The full name of the command: power-off or reboot the machine
  • Location: /usr/sbin/shutdown
  • Execution authority: root
  • Function description: Shut down and restart
命令格式
shutdown [选项] 时间 [警告信息]
常用选项:
-h:关机
-r:重启
-c:取消shutdown已经执行的指令

1. Shut down

Shutdown directly means that the computer will automatically shut down after one minute.

[root@snljh ~]# shutdown
Shutdown scheduled for Thu 2021-03-11 10:30:17 CST, use 'shutdown -c' to cancel.
[root@snljh ~]#
Broadcast message from root@snljh (Thu 2021-03-11 10:29:17 CST):

The system is going down for power-off at Thu 2021-03-11 10:30:17 CST!

If we want to cancel this operation, shutdown -c will do.

[root@snljh ~]# shutdown -c

Broadcast message from root@snljh (Thu 2021-03-11 10:29:31 CST):

The system shutdown has been cancelled at Thu 2021-03-11 10:30:31 CST!

If we want to shut down immediately, shutdown -h now or shutdown -h 0 will do.

[root@snljh ~]#shutdown -h now
[root@snljh ~]#shutdown -h 0

If we want the system to shut down automatically after 10 minutes, shutdown -h 10 will do.

[root@snljh ~]# shutdown -h 10(10这个位置就是填写分钟数)
Shutdown scheduled for Thu 2021-03-11 10:48:16 CST, use 'shutdown -c' to cancel.
[root@snljh ~]#
Broadcast message from root@snljh (Thu 2021-03-11 10:38:16 CST):

The system is going down for power-off at Thu 2021-03-11 10:48:16 CST!

2. Restart

Restarting is very simple, just change the option, shutdown -r now means to restart immediately

[root@snljh ~]# shutdown -r now

to sum up

In this section we learned

{ Shutdown shutdown: shutdown -h time shutdown restart: shutdown -r time }


Guess you like

Origin blog.csdn.net/qq313088385/article/details/114652292