How to Reboot Linux Server From Command Line?

Reboot refers to a process that closes and restarts the operating system from its initial boot-loading sequence. In Linux, it is recommended to reboot the system to resolve common problems such as slow processing, excessive heating, system updating, and much more. Linux servers are also rebooted to apply any configuration to the system.

This post notes down all possible aspects to reboot the Linux server from the command line with the following outline:

Method 1: Using the “reboot” Command

The “reboot” command is used to reboot or restart the Linux server. By default, It is pre-installed in most Linux distributions. Simply type the “reboot” command in the terminal and press the “Enter” key to reboot the current Linux system:

$ reboot

The system will be rebooted after a few seconds.

Apart from that, execute the below-mentioned reboot command as a root user. It shuts down the single-user system without warning the other users on the system shutdown: 

# /sbin/reboot

Tip: To check how many times your Linux system rebooted then, execute the “reboot” command with the “last” keyword in this way:

$ last reboot

Method 2: Using the “systemctl” Command

The “systemctl” utility can also be used to reboot the Linux server as follows:

$ sudo systemctl reboot

Display a Message Before Reboot

If the user wants to display a custom message before rebooting the Linux system, then use the “systemctl” with the  “–message= option” in this way:

$ sudo systemctl --message="Installed Pacakge" reboot

Method 3: Using the “shutdown” Command

By default, the shutdown command powers off the Linux system. For rebooting, use its “-r” flag in this way:

$ shutdown -r now

Reboot At Specific Time

The “shutdown” command is also beneficial to shut down the system at a specific time. For instance, the command below will shut down the system after “10 minutes”, from now: 

$ shutdown -r +10

The system will be rebooted after 5 minutes.

Display the Message Before Reboot

To display a custom message or notification when the system reboots, use the “shutdown” command in the following way:

$ shutdown -r +15 "System update"

The rebooting is scheduled after 15 minutes due to system update.

Cancel the Rebooting

If the user wants to cancel the rebooting process, then use the “-c(cancel)” flag with the “shutdown” command:

$ shutdown -c

The Linux system rebooting has been canceled.

Note: Read our article here for more details on the shutdown command. 

Conclusion

Linux server can be rebooted using the “reboot”, “systemctl”, and “shutdown” command line utilities. The “reboot” and “systemctl” commands reboot the system after a few seconds, while the “shutdown” reboots the system after one minute by default. This guide has illustrated all possible ways to reboot the Linux server.