Restarting a Linux Server is a significant part of the Linux system administration. When you install critical system updates or your server’s performance starts deteriorating, then rebooting Linux system becomes a requirement. Rebooting the system loads a clean and fresh copy of the Linux operating system into active memory. Linux offers various commands and methods to restart or reboot your Linux computer.
In this tutorial, we will cover the three most used commands to reboot a Linux server.
- A working Linux system.
- Access to the command-line interface.
- Root or sudo privileges to execute sudo command.
- SSH command package or putty software packages to establish a connection with the remote Linux system.
1. Using systemctl Command
The systemctl utility offers multiple power management commands for Linux system administrators. You can use the systemctl reboot and restart commands to power down your Linux operating system.
When you initiate a system reboot, all the currently logged-in users are notified about the system reboot and new user logins are disabled. All open files are closed, the running processes are stopped, and the system is rebooted to load a fresh copy of the operating system into the memory.
To immediately restart your computer using the systemctl command and notify all logged-in users about the system reboot, enter the following command:
sudo systemctl reboot
If you do not want to send a notification to the currently logged-in users about the system reboot, then use the --no-wall option:
sudo systemctl --no-wall reboot
You can also include a custom message for the users along with the default reboot notification using the --message option:
sudo systemctl --message="OS upgrade, will be back in 30 minutes" reboot
Entering the Firmware Update Mode
The systemctl command-line interface also lets you directly access the firmware setup menu of your Linux machine:
systemctl reboot --firmware-setup
This option is not supported on all most modern Linux distributions and thus you may get an error:
If it does not work on your Linux operating system, then press the Shift key during system boot time to enter the Firmware update mode, also known as recovery mode.
2. Using reboot Command Linux
The most common and the original command for rebooting your computer is to use the Linux reboot command. This command is also an alias to the sudo shutdown -r command.
Using the Linux reboot command is simple. Just type the command reboot and your system immediately restarts:
The reboot Command Options
Reboot provides various options that you can use to control the behaviour of this command, as described in the below table:
|Forcefully reboots your Linux operating system. Performs clean restart by the system manager when used once. When used twice, it performs immediate shutdown without informing the system manager.|
|Powers off your system immediately.|
|Writes only the wtmp shutdown entry but does not reboot your computer.|
|Writes detailed message when rebooting, which is useful to debug reboot problems.|
Reboot vs systemctl reboot
The systemctl reboot command offers only one option to immediately reboot your computer. However, the reboot command provides other options, such as -f (force), -p (power off), and -w (write wtmp only). When you use systemctl reboot, it calls the reboot command in the background without any options.
3. Using shutdown Commands
You can use the shutdown commands primarily to turn off your computer, but this command can also be used with the -r option to reboot your computer.
The shutdown commands are available on all Linux distributions. By default, the sudo shutdown -r command restarts your computer after one minute. To reboot your Linux system immediately, use the now option:
sudo shutdown -r now
To schedule a reboot using the shutdown command, specify the number of minutes after the shutdown -r command. The following example show you how to reboot your computer five minutes after executing the command:
sudo shutdown -r +5
As described in the output above, you can use the sudo shutdown -c command to cancel the scheduled reboot.
Schedule a Reboot
The shutdown command can be used to schedule a reboot using the time variable. The following two different time formats are supported for scheduling a reboot:
- Absolute time – An exact time in the hh:mm time format. For example, to schedule a reboot at 8 AM, use 08:00.
- Relative time – Number of minutes in the +m format, such as to start after 10 minutes use +10.
You can broadcast a custom message when scheduling a reboot to let the current users know why the system is rebooting and when will it be back.
The systemctl command line utility can also be used to schedule a reboot by restarting the reboot.target service periodically.
4. Additional Reboot Options
Along with the options described in the above sections, Linux provides the following additional reboot options:
Reboot Using Run Level
You can reboot your Linux system by setting the runlevel to 6 using the following telinit command:
sudo telinit 6
Runlevel can also be used to shut down your computer by using the following command:
sudo telinit 0
Reboot Using Sysrq
You can also use the /proc file system to reboot your system. The /proc file system is a virtual depiction of everything that that is happening on your computer. The following example shows how to restart your computer using Sysrq:
sudo echo b > /proc/sysrq-trigger
This is not a practical method to restart your computer, but you can use it in special circumstances and it gets the job done.
Reboot Using Sysctl
You can also reboot your computer by using a kernel panic method to simulate a crash. The following procedure depicts how to reboot using sysctl:
1. Enable Sysrq to try this method:
sudo echo 1 > /proc/sys/kernel/sysrq
2. Simulate a system crash:
sudo echo c > /proc/sysrq-trigger
Your system reboot immediately.
5. Reboot a Remote Linux Server
As a Linux system administrator, you may manage multiple computers, including remote servers or clients. The basic method is to connect to the server using SSH command and then run the reboot command:
Connect to the remote Linux system:
ssh [email protected]_server
Run the reboot command on the remote server:
You can also perform both the operations in a single command:
ssh -t [email protected]_server ‘sudo reboot’
This tutorial describes multiple options to reboot your computer, but you don’t have to use them all. You must choose a method that is suitable for the operation that you are trying to accomplish. Do not use a method that can damage your computer unless you really must. Some of the additional options described in this article may not work on all Linux distributions.