Knowledgebase

How to Restart/Reboot Linux Server by Command?

Introduction

If you manage a Linux server, knowing how to restart or reboot it properly is essential.

But the question is whether rebooting a server is necessary.

Whether you are looking to:

  • Applying system updates
  • Fixing system slowdowns
  • Restarting stuck services
  • Resolving memory leaks
  • Reconfiguring system settings

Rebooting the server can help restore normal operations!

In this guide, we will discuss the correct methods to restart your Linux server using simple commands. Whether you are a beginner or an experienced administrator, these steps are easy to follow.


Also Read: How to Create a New Group in Linux?


What are Prerequisites & Precautions?

  • Access to the server: You must have SSH or direct terminal access.
  • Ensure Remote Access: If you are rebooting remotely, ensure the SSH connection is stable.
  • Root or sudo privileges: In most restart commands, you require administrative privileges.
  • Save any unsaved work: Before rebooting, save important files & prevent any file losses.
  • Notify users: If you are running client’s work on the servers, inform them before rebooting.
  • Check running processes: Ensure no critical operations are running by using ps aux or htop:
  • Verify system logs: Check system logs for errors before rebooting using journalctl -xe or dmesg.
  • Backup Data: Always keep your important files and databases backed up.


Also Read: Know About the ls Command in Linux With Examples


Commands to Restart a Linux Server

Method 1: Using the ‘reboot’ Command (Recommended)

The reboot command is the most straightforward and widely used method for restarting a Linux server. The best part is that it works on most Linux distributions. This command safely shuts down all running processes, unmounts file systems, and reboots the machine.

To restart your server immediately, you can simply run:

sudo reboot


Also Read: Create Zip File With Command in Linux With Examples


Method 2: Using the ‘shutdown’ Command

The shutdown command provides more control over the restart process. The benefit of using this command is that it allows you to schedule reboots and notify users before the system restarts. This command can be useful to give users advance notice before restarting the system.

➔ To restart the server immediately, you have to use:

sudo shutdown -r now

Here:

  • -r flag is for rebooting.
  • now means an immediate restart.

This command will immediately restart the system after properly shutting down all running processes.

➔ If you are looking to schedule a restart after a specific time (e.g., after 5 minutes), use the following:

sudo shutdown -r +5 “Server will reboot in 5 minutes”

This will reboot the server after 5 minutes, which allows users to save their work before the restart.


You can also set a specific time for rebooting. For example, to restart the server at 10:30 PM, you have to use:


sudo shutdown -r 22:30

To cancel a scheduled restart, you have to use:

sudo shutdown -c

As a result, this command will stop any scheduled shutdown or reboot, preventing unexpected restarts.


Also Read: A Guide to Echo Command in Linux With Examples


Method 3: Using the init Command

The init command is an older method of rebooting a Linux server by changing its runlevel. It provides a structured way to transition the system between different states. The runlevel determines the system’s state, such as shutdown, reboot, or normal operation.

However, modern Linux distributions have moved away from the init system in favor of systemd. Therefore, using systemctl reboot is preferred for newer systems.

To restart the server using the init command, you have to run:

sudo init 6

Using this command changes the system’s runlevel to 6, which is designated for rebooting.


Also Read: How To Remove Directory in Linux With Command?


Method 4: Using the systemctl Command (For Systemd-based Linux)

For modern Linux distributions that use systemd, the systemctl command is the preferred method for restarting a server. It is recommended for modern Linux distributions like Ubuntu (16.04+), CentOS (7+), and Debian (8+).

To restart the server, you have to run:

sudo systemctl reboot

This command instructs the systemd to shut down all running services and reboot the system cleanly.

More control over system services allows you to check and manage running processes before rebooting.

To check active services before restarting, you have to use:

sudo systemctl list-units –type=service –state=running

This helps you confirm if any critical processes are running before issuing a reboot.

If you want to force a reboot without waiting for processes to stop, use:

sudo systemctl reboot –force

*Note: This command should be used cautiously, as it may cause data loss if applications are still writing to disk.


Also Read: How to Change Server Time in Linux?


Method 5: Restarting Using the halt Command


The halt command is primarily used to stop the system but can also be used to restart the server by adding the -r option.


This method can be useful when you need a quick restart and doesn’t require additional options provided by shutdown or systemctl.

To restart the server using the halt command, run:

sudo halt -r

*Note: Using halt without the -r flag will shut down the system instead of rebooting it.


Also Read: How to Create a User in Linux & Add it to the sudoer File?


Conclusion

Rebooting a Linux server is a simple yet crucial task that ensures system stability, applies updates, and resolves performance issues. While a graceful restart using commands like sudo reboot or sudo shutdown -r now is the best approach, knowing alternative methods can be a lifesaver when dealing with unresponsive servers.

Before hitting that restart button, always check active services, notify users (if applicable), and schedule the reboot strategically to minimize downtime. If rebooting remotely, ensure a stable SSH connection to avoid unexpected disruptions.

Remember, a well-managed reboot keeps your server running smoothly without unwanted surprises.

Reboot Smart, Not Hard!

Hidden-Costs-and-Fees
Get a VPS Server That Don’t Affect Your Pocket

VPS hosting at an affordable price with Top-class features