How to Reboot Linux Server [6 Effective Methods]

Written by

Reviewed by

Last updated: June 13, 2024

Expert verified

SVG Image

TL;DR

To reboot Linux server, you can try these three methods:

  1. Reboot Linux server immediately using the sudo reboot command.
  2. Reboot the server with options such as scheduling a reboot or specifying a delay using the sudo shutdown -r now command.
  3. Reboot Linux server when it is unresponsive using the Alt + SysRq + r + e + i + s + u + b key sequence.

Explore different methods to reboot Linux server in the guide below. Also, learn how to do scheduled reboots, best practices to follow, and common errors that can occur during the process.

Ever faced issues with your Linux server and wondered if a reboot might help? Rebooting can often solve performance issues, apply crucial updates, and fix bugs. In this post, I’ll show you when and how to reboot your Linux server, prepare for it by backing up data and notifying users, and troubleshoot common errors. You’ll find step-by-step instructions for various reboot methods and learn best practices to ensure everything goes smoothly. Let’s dive in and keep your server running efficiently.

When You Need to Reboot Linux Server

Rebooting a Linux server can help fix many issues and keep your system running smoothly. Here are some common situations when you should consider rebooting:

  1. Installing Kernel Updates: After updating the Linux kernel, you need to reboot the server for the changes to take effect. The kernel is the core part of the operating system, and updates often include important security patches and performance improvements.
  2. Applying Major System Updates: Some system updates, especially those affecting core components, require a reboot. This ensures that all new changes load correctly and your server runs efficiently.
  3. Fixing Performance Issues: If your server becomes slow or unresponsive, a reboot can help clear temporary files and free up memory. This can restore normal performance and resolve minor glitches.
  4. Clearing System Errors: Rebooting can solve certain system errors or software bugs. When applications or services behave unexpectedly, a fresh start often fixes the problem.
  5. Testing Configuration Changes: After making significant configuration changes, such as modifying network settings or installing new software, a reboot can ensure everything integrates properly and functions as expected.
  6. Recovering from Hardware Issues: Rebooting can help detect and address hardware problems. For instance, if your server can’t access a hard drive or other hardware component, a reboot may help the system recognize and use the hardware correctly.
  7. Routine Maintenance: Regularly scheduled reboots can prevent issues from accumulating over time. Routine maintenance ensures that your server stays in good health and reduces the likelihood of unexpected downtime.

Preparing for a Server Reboot

Before rebooting a Linux server, it’s important to take a few key steps to ensure everything goes smoothly. Here’s what you should do:

  • Backing Up Data: First, back up all important data and configurations. This step is crucial because it protects your information in case something goes wrong during the reboot. You can use backup tools or manual methods to create these backups. Having a recent backup means you can quickly restore your system to a working state if needed.
  • Notifying Users and Stakeholders: Next, inform everyone who might be affected by the reboot. This includes users who rely on the server and any stakeholders who need to know about potential downtime. Send out a notification explaining when the reboot will happen and how long it might take. Clear communication helps avoid surprises and allows users to plan around the downtime.
  • Checking for Running Critical Processes: Lastly, check if any critical processes are running on the server. Use commands to see which applications or services are currently active. Make sure you properly stop or save the work for these processes to prevent data loss or corruption. Knowing what’s running helps you ensure everything shuts down and restarts correctly.

How to Restart Linux Server

To reboot Linux server, you have several options. Use the sudo reboot command for a quick restart. Alternatively, use sudo shutdown -r now to reboot immediately or schedule it with sudo shutdown -r +10 to reboot in 10 minutes.

For systems using systemd, sudo systemctl reboot works well. If these don’t work, echo b | sudo tee /proc/sysrq-trigger is a low-level method for emergency reboots. Always back up data and notify users before rebooting to ensure a smooth process.

That was the quick answer. Here are six different methods to restart Linux server:

1. reboot Command

The Linux server reboot command is a simple and straightforward way to reboot a Linux server. It is best used when you need to initiate a quick and immediate reboot of the server. Follow these steps:

  1. Open the command line interface.
opening terminal 9
  1. Execute the Linux reboot command: 
sudo reboot
  1. This command requires root privileges, so it may prompt you for the root password. After entering the password, the server will initiate a reboot process.
rebooting linux server

2. shutdown Command

The shutdown command provides more control over the reboot process. It is best used when you want to schedule a reboot or when you require additional options for shutting down and restarting the server. Follow these steps:

  1. Enter your Terminal window and execute the following command: 
sudo shutdown -r now

The -r option indicates a reboot. The now keyword specifies an immediate reboot. Enter the root password if prompted.

The server will begin the shutdown process, followed by a reboot.

immediately shutting down rebooting linux server

3. SysRq Magic Keys

Leveraging SysRq Magic Keys is used when your Linux server becomes unresponsive, and traditional reboot methods do not work. This method allows you to switch the keyboard to raw mode, send signals to processes, sync file systems, and remount them in read-only mode before triggering the reboot. Follow these steps to restart Linux server:

  1. Press and hold the Alt and SysRq (Print Screen) keys simultaneously.
press and hold the keys
  1. While holding those keys, enter the following key sequence: r → e → i → s → u → b.
  2. Each key corresponds to a specific action:
    • r: Switch the keyboard to raw mode.
    • e: Send a SIGTERM signal to all processes except init.
    • i: Send a SIGKILL signal to all processes except init.
    • s: Sync all mounted file systems.
    • u: Remount file systems in read-only mode.
    • b: Reboot the system.
  3. Release the keys, and the server will initiate a reboot.
pressing keys in a sequence

4. init Command

The init command is a traditional way to change the runlevel of a Linux system. Runlevel 6 is specifically designated for rebooting the system. This method is straightforward and reliable for systems that still use the traditional SysVinit.

  1. To reboot the system using the init command, execute:
sudo init 6

This command changes the runlevel to 6, which initiates a system reboot.

rebooting system using init command
  1. You can check the current runlevel using the runlevel command:
runlevel

This will show you the previous and current runlevel, helping you understand the system’s state.

viewing current runlevel of system

5. systemctl Command

The systemctl command is part of systemd, the modern init system used by most Linux distributions today. It provides a more consistent and powerful way to manage services and system states, including reboots. Follow these steps to restart Linux server using systemctl command:

  1. In your Terminal run the following command to reboot the system immediately with systemctl:
sudo systemctl reboot

This command tells systemd to perform an immediate reboot.

rebooting system using systemctl command

6. halt Command

The halt command is traditionally used to stop all CPU functions. When used with the -r option, it initiates a reboot instead of halting the system.

  1. Launch your Terminal window and execute the following command to reboot the system using the halt command:
sudo halt -r

The -r flag tells the system to reboot instead of halting. This method reboots the system immediately without any delay or notifications.

rebooting system using halt command

How to Do Scheduled Reboots of Linux Server

Scheduled reboots are best used to maintain server stability and performance by regularly restarting the system. By using cron jobs, you can automate the process of scheduling reboots at specific times. Follow these steps to create a scheduled reboot task using cron jobs:

  1. Launch your command window.
  2. Execute the command: 
crontab -e
  1. The command will open the crontab configuration file.
opening crontab configuration file
  1. In the crontab file, add a new line with the following syntax to schedule a reboot at a specific time. For example, to reboot the server every Sunday at 3 AM, add the line:
0 3 * * 0 sudo reboot
  1. This line represents the minute, hour, day of the month, month, and day of the week, respectively.
  2. Save the file and exit. The server will automatically reboot according to the defined schedule.
scheduling a reboot time in ubuntu

3 Best Practices for Server Rebooting

When it comes to reboot a Linux server, following best practices ensures a smooth and successful process while minimizing potential issues. By adhering to these best practices, you can mitigate potential risks, maintain system stability, and optimize the server reboot process for your Linux server environment. Here are three best practices to follow:

  • 🔒 Take Regular Backups: Before rebooting, take regular backups of important data and configurations. This protects against data loss and allows system restoration if needed.
  • 🔄 Keep Your System Up to Date: Ensure your server is up to date with the latest patches and updates. This enhances performance, security, and stability. Use package managers or automated tools for updates.
  • 🔎 Check Service Dependencies: Identify and understand service dependencies to avoid disruptions. Ensure services stop and start in the correct order to prevent conflicts and minimize risk.

3 Common Errors When Rebooting a Linux Server

Rebooting a Linux server is a crucial task, but it can sometimes encounter errors that may disrupt the process. Understanding these common errors and their solutions can help ensure a successful server reboot. Here are three frequent errors that you may encounter while rebooting a Linux server:

  • ⚠️ “Failed to Unmount File System” Error: Occurs when a file system is still in use or has open files. This prevents proper shutdown and may cause data corruption. To resolve, manually close open files or processes associated with the file system before rebooting.
  • ⛔️ “Service Not Responding” Error: Happens when a service fails to stop gracefully. This can prolong the reboot or prevent it entirely. To fix, forcibly terminate the unresponsive service using commands like kill or systemctl. Ensure services are configured for graceful shutdowns.
  • 💥 “Kernel Panic” Error: A critical error indicating an issue with the Linux kernel, leading to system freeze or reboot loops. Causes include hardware failures, incompatible drivers, or misconfigurations. Troubleshoot by analyzing logs, checking hardware compatibility, and updating patches and drivers. Consult experienced administrators or online resources if needed.

Reboot Linux Server Command Line: Wrapping Up

In this article, I’ve explored various methods to reboot Linux server, like reboot, shutdown, init, systemctl, and using the magic SysRq key. I’ve also covered preparing by backing up data, notifying users, and checking processes. By following these steps, you can ensure smooth reboots and maintain system stability while effectively troubleshooting common errors.

For further learning, I recommend reading about:

Frequently Asked Questions

Will rebooting my server affect the running applications and services?

Yes, rebooting a Linux server will interrupt running applications and services. When a server is rebooted, all processes and services are stopped and then restarted as part of the reboot process. This interruption can lead to temporary unavailability or loss of unsaved data in active applications. To minimize the impact, it is important to gracefully stop services before initiating a reboot. This allows them to shut down properly, ensuring that any pending tasks are completed or saved.

How often should I reboot my Linux server for optimal performance?

The frequency of reboots for optimal server performance depends on various factors, such as the nature of the workload, system stability, and resource usage patterns. While Linux servers are known for their ability to run for extended periods without requiring reboots, periodic reboots can help maintain system stability and ensure optimal performance. It is recommended to schedule regular reboots based on your specific requirements. This can be daily, weekly, or monthly, depending on the workload and the need for applying system updates or resolving memory leaks.

Is it necessary to notify users before rebooting a server?

Yes, it is essential to notify users before rebooting a Linux server to minimize potential data loss or interruptions. Notifying users in advance allows them to save work, close applications gracefully, and prepare for the upcoming reboot. This is particularly important for servers hosting critical services or applications where unexpected interruptions can have significant consequences. Providing clear communication about the scheduled reboot enables users to plan their activities accordingly and make necessary arrangements.

Ojash

Author

Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

Akshat

Reviewer

Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Check Crontab Logs in Linux [3 Effective Methods]

Next Post

How to Install FFmpeg Ubuntu [2 Best Methods]

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next