Introduction
Knowing how to restart a Linux server is crucial for routine maintenance, troubleshooting, and applying updates. It allows for the implementation of configuration changes, resolves performance issues, and frees up system resources tied up by different processes.
Regular restarts contribute to system health by preventing the accumulation of problems that arise from continuous uptime.
This guide teaches you how to restart/reboot a Linux server.
Prerequisites
- A Linux operating system (this tutorial uses Ubuntu 22.04).
- Access to the Terminal.
- Root or sudo privileges.
- SSH software package (for some examples).
Restart Linux Server via the reboot Command
The basic command for restarting Linux is reboot
. Depending on the system, sudo or root permissions may be required to execute this command.
Step 1: Open Terminal
The most popular way to manage your Linux system is via the terminal. These two methods are the easiest ways to open a terminal window:
- The keyboard shortcut. Press Ctrl + Alt + T simultaneously on your keyboard to open the Terminal application.
- Applications menu. Open the applications menu, search for "Terminal," and click the icon to open the application.
To open the terminal on a remote server, use the ssh
command to connect to it. The syntax is:
ssh [username]@[your_server_ip]
Replace username
with your username and your_server_ip
with your server's IP address or hostname.
Step 2: Use reboot Command
Once you open the terminal, use the reboot
command to restart the server. In most cases, users need sudo privileges to use this command and restart a Linux server:
sudo reboot
The command prompts for the user password to confirm the administrative privileges before initiating the system restart. For some accounts, sudo privileges are not necessary
Step 3: Wait for Reboot to Complete
Once you issue the command, the system restarts. The screen goes blank, and you see different messages or errors, if any. Then, the operating system logo appears, and the machine boots back up.
The time a Linux server takes to reboot depends on multiple factors, including the installed hardware or assigned resources if you are using a VM.
Restart Linux Server via the shutdown Command
The shutdown command is a common and efficient way to initiate a reboot. It instructs the system to restart by specifying the -r
option.
Run the shutdown command with the argument -r
now to restart the Linux server immediately:
sudo shutdown -r now
Note: If you want to schedule a restart for a later time, replace now
with a specific time in the format hh:mm
.
Since the command requires sudo, type in the password when prompted. The command has no output.
Restart Linux Server via init Command
Using the init
command to restart a Linux server is an older method, and it's mostly replaced with systemctl
or reboot
commands.
However, SysVinit system users may still want to restart the server using the init
command:
sudo init 6
The init 6
command is traditionally used to trigger a system reboot. It is a runlevel defined in the SysVinit system, where runlevel 6 corresponds to a reboot.
Next, provide the password when prompted:
Wait for the server to complete the restart process. The command leaves no output, but it does restart the system.
Restart Linux Server via systemctl Command
Systemd, the system and service manager in many modern Linux distributions, is designed to provide a high degree of control and flexibility. The systemctl command allows administrators to manage services, view their status, start or stop them, and restart them individually.
Note: To restart a Linux server using the systemctl
command, you need sudo or root privileges.
To reboot Linux, use the following command
sudo systemctl reboot
The command prompts for a password before restarting. Since this command requires sudo privileges, provide the password when prompted and hit Enter.
The command has no output but initiates the restart process for the entire system. The process takes up to a few minutes.
Conclusion
After reading this tutorial, you now know how to restart the Linux server using multiple methods.
Next, learn how to start, stop, and restart services in Linux.