Sep 25, 2023 3 min read

Linux Reboot (Restart) Command

In this tutorial, we'll show you how to reboot your Linux machine with the systemctl and shutdown commands.

Linux Reboot (Restart) Command
Table of Contents

Introduction

Unless you're using Livepatch or KernelCare, you'll need to reboot your Linux system when the kernel is updated. In some cases, a system reboot is essential, such as when debugging hardware issues, installing apps, and so on. You'll need to know how to restart a headless Linux server from the command line if you're using it.

The systemctl utility replaces most of the power management commands used in previous Linux versions with sysvinit in most recent Linux variants. The commands reboot and shutdown are aliases for systemctl and are included in the system for compatibility.

In this tutorial, we'll show you how to reboot your Linux machine with the systemctl and shutdown commands. Run the commands as root or as a user with sudo access. We will also address a few FAQs on Linux Reboot (Restart) Command.

systemctl

Simply type reboot or systemctl reboot to restart your Linux system:

sudo systemctl reboot

The system will be restarted as soon as possible.

All logged-in users and processes are warned that the system is going down when the reboot is triggered, and no additional logins are permitted. All open files will be closed, running programs will be stopped, and the system will be restarted.

Run the reboot command with the --no-wall option to prevent it from transmitting a message:

sudo systemctl --no-wall reboot

Use the --message= option to specify a custom message describing the cause for the reboot:

sudo systemctl --message="Hardware upgrade" reboot

The following message will appear in the logs:

System is rebooting (Hardware upgrade)

shutdown

The shutdown command conducts a system reboot when used with the -r option:

sudo shutdown -r 

The system will reboot after 1 minute by default, but you can select a specific time when you want it to reboot.

There are two possible formats for the time argument. It can be an absolute time formatted as hh:mm or a relative time formatted as +m, where m is the number of minutes from now.

The example below will reboot the system at 10 a.m.:

sudo shutdown -r 10:00

The example below will cause the system to reboot in 5 minutes:

sudo shutdown -r +5

Use +0 or its alias now to shut down your system immediately:

sudo shutdown -r now

Type your message after the time parameter to broadcast a custom message along with the usual shutdown notification.

The following command will shut down the system in 10 minutes and warn users that a hardware update is being performed:

sudo shutdown -r +10 "Hardware upgrade"

When using a custom wall message, it's vital to note that you must supply a time parameter.

If you want to cancel a planned reboot, use the shutdown command with the -c option:

sudo shutdown -c

You can also send out a note explaining why the reboot has been postponed:

sudo shutdown -c "Canceling the reboot"

FAQs on Linux Reboot (Restart) Command

Is there a delay option for the reboot command? 

Yes, you can use the -d or --delay option followed by a time argument to specify a delay before rebooting. For instance, sudo reboot -d 5 will reboot the system after a 5-second delay.

Are there any additional options for the reboot command? 

Yes, the reboot command provides other options such as -f (force immediate reboot), -h (halt instead of reboot), and -w (only write a system reboot record without performing the actual reboot).

How can I cancel a reboot initiated by the reboot command? 

You can cancel a reboot initiated by the reboot command by using the Ctrl + C keyboard shortcut within the time limit specified for the reboot (usually a few seconds).

Does the reboot command require root privileges? 

Yes, the reboot command typically requires root privileges to perform a system reboot. Using sudo reboot ensures you have the necessary permissions.

Can I schedule a future reboot with the reboot command? 

No, the reboot command does not have built-in functionality for scheduling future reboots. You may need to use tools like at or cron to schedule a reboot at a specific time.

How can I force an immediate reboot using the reboot command? 

To force an immediate reboot, you can use the -f or --force option. It terminates running processes without a clean shutdown, which can potentially result in data loss or corruption.

Are there any alternatives to the reboot command? 

Yes, other alternatives to the reboot command include the shutdown command, which also allows you to restart or power off the system with additional options for scheduling and notifications.

Conclusion

In your terminal, type reboot to reboot a Linux system. The operating system will take a few moments to restart.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.