OSETC TECH

How To Reboot System Using Command Line in Linux

This post will guide you how to reboot Linux server from the command line. How do I restart your system using reboot or shutdown command from the command line in your Linux system.

Reboot Command


Reboot command may be used to halt, power-off or reboot the machine.

The syntax of the Shutdown command is as follows:

reboot [OPTIONS...]

Options:
The following options are understood:

--help Print a short help text and exit.
--halt Halt the machine, regardless of which one of the three commands is invoked.
-p, --poweroff Power-off the machine, regardless of which one of the three commands is invoked.
--reboot Reboot the machine, regardless of which one of the three commands is invoked.
-f, --force Force immediate halt, power-off, or reboot. When specified once, this results in an immediate but clean shutdown by the system manager. When specified twice, this results in an immediate shutdown without contacting the system manager. See the description of –force in systemctl(1) for more details.
-w, --wtmp-only Only write wtmp shutdown entry, do not actually halt, power-off, reboot.
-d, --no-wtmp Do not write wtmp shutdown entry.
-n, --no-sync Don’t sync hard disks/storage media before halt, power-off, reboot.

Shutdown Command


Shutdown command may be used to halt, power-off or reboot the machine.

The syntax of the Shutdown command is as follows:

shutdown [OPTIONS...] [TIME] [WALL...]

Options:
The following options are understood:

--help Print a short help text and exit.
-H, --halt Halt the machine.
-P, --poweroff  Power-off the machine (the default).
-r, --reboot Reboot the machine.
-h Equivalent to –poweroff, unless –halt is specified.
-k Do not halt, power-off, reboot, just write wall message.

Reboot Your Linux System using Reboot Command


If you want to reboot the Linux system from the command line, and you need to make sure that the user you are currently logged in as superuser or have sudo privileges. Then you can type the following reboot command to reboot your current Linux system:

$ sudo reboot

or

$ reboot

Note: you need to wait for some time and your Linux server will be rebooted.

Reboot Your Linux System using Shutdown Command


You can also use another command shutodwn to reboot your Linux system, just type the following command:

$ sudo shutdown -r

If you want to reboot your system immediately, and you can use one of the following command:

$ sudo shutdown -r 0

or

$ sudo shutdown -r now

If you want to reboot your system in five minutes, and you can use the following shutdown command:

$ sudo shtudown -r 5

Outputs:

[devops@mydevops ~]$ sudo shutdown -r 5
Shutdown scheduled for Sat 2019-10-12 04:54:51 EDT, use 'shutdown -c' to cancel.

If you want to reboot your system in 15 minutes and write a message to all users currently logged in, and you can run the following shutdown command with “-r” option, type:

$ shutdown -r 15 "this system will be rebooted in 15 minutes"

If you want to reboot the remote Linux server using ssh command, you can type the following command:

$ ssh root@remoteServer /sbin/reboot

Or

$ ssh root@remoteServer /sbin/shutdown -r now

Conclusion


You should know that how to reboot your Linux system using reboot/shutdown commands in your CentOS/RHEL/Ubuntu Linux.