Sometimes you need to remotely reboot or shut down the Linux-based operating system from the command line. This can be done in various ways, we will consider them.
All below listed commands should be executed from under the "root" user.
To change the user or get root rights, use the command "su -" or "sudo".
Reboot the Linux
Use the "shutdown" command with key -r
The shutdown command is the main command to control stopping or restarting a linux system.
[root@linux ~]# shutdown -r now
When using the "shutdown" command, you can specify a reboot at a specific time with the display of informative messages.
[root@linux ~]# shutdown -r 10:30 "REBOOT SYSTEM"
Use the "reboot" command
The "reboot" command performs all the necessary operations to stop the system, this command can be called with the command "shutdown -r", but can be used separately. This command logs the system shutdown time to the log, destroys incomplete processes, performs the sync system call, waits for the disk to write, and then stops the kernel and reboots the Linux system.
[root@linux ~]# reboot
Use the "telinit 7" command
With this command, you can set the init daemon to go to a certain level of execution, namely, the number 7 indicates that you need to go to the 7th level (reboot). The telinit command does not support pause and warning messages. Usually used when checking changes made to the "inittab" file.
[root@linux ~]# telinit 7
Shutting down Linux
Use the "shutdown" command with key -h
[root@linux ~]# shutdown -h now
Use the "halt" command.
The command is identical to the reboot command in its actions, the difference is that the halt command shuts down the system.
[root@linux ~]# halt
Use the "poweroff" command
The "poweroff" command is identical to the "halt" command, except that after stopping the system, a special request is sent to the power management system to turn off the power, which allows the system to be remotely shut off.
[root@linux ~]# poweroff
Use the "telinit 0" command
Identical to the "telinit 7" command only goes to level 0, which means that the system is stopped.
[root@linux ~]# telinit 0
That's all, consideration of the main ways to shut down and restart Linux systems from the command line is completed. Comment, subscribe. Bye everyone.
Comments powered by CComment