Read in 3 minutes

last updated 

How to Reboot Linux Using the Command Line

Sometimes when debugging an issue or updating the kernel you may need to reboot your Linux system. If you have a headless server you need to know how to restart the system from the command line.

On the modern Linux distributions, the systemctl utility replaces the most of power management commands used in the older Linux distributions with sysvinit. Old reboot and shutdown commands are aliases to systemctl and are available in the system for compatibility reasons.

In this tutorial, we will show you how to use the systemctl and shutdown commands to reboot your Linux machine. The commands must be run as root or user with sudo privileges.

How to Reboot Linux using systemctl Command

To reboot your Linux system run the systemctl utility with the reboot command:

sudo systemctl reboot

The system will be restarted immediately.

When the reboot is initiated, all logged-in users and processes are notified that the system is going down, and no further logins are allowed.

To prevent the reboot command from sending a message, run the command with the --no-wall option:

sudo systemctl --no-wall reboot

If you want to set a custom message explaining the reason for the reboot, use the --message= option:

sudo systemctl --message="Hardware upgrade" reboot

The message will be shown in the logs:

System is rebooting (Hardware upgrade)

How to Reboot Linux using shutdown Command

To reboot your Linux system use the shutdown command with the -r option:

sudo shutdown -r 

By default, the system will be rebooted after 1 minute, but you can specify the exact time when you want the system to be rebooted.

The time argument can have two different formats. It can be an absolute time in the format hh:mm and relative time in the format +m where m is the number of minutes from now.

The following example will schedule system reboot at 10 A.M:

sudo shutdown -r 10:00

The following example will schedule system reboot in 5 minutes from now:

sudo shutdown -r +5

To shut down your system immediately use +0 or its alias now:

sudo shutdown -r now

To broadcast a custom message along with the standard shutdown notification type your message after the time argument.

The following command, will shut down the system in 10 minutes from now and notify the users that a hardware upgrade will be performed:

sudo shutdown -r +10 "Hardware upgrade"

It is important to mention that when specifying a custom wall message you must specify a time argument too.

If you have scheduled reboot and you want to cancel it, run shutdown command with the -c option:

sudo shutdown -c

You can also broadcast a message describing why the reboot was canceled:

sudo shutdown -c "Canceling the reboot"

Conclusion

In this tutorial, we have shown you how to reboot your Linux machine from the command line.

Feel free to leave a comment if you have any questions.