Search Our Database

How to reboot a server safely via Command Line

Last updated on |
by

Introduction

Rebooting a server is a critical administrative task that may be necessary after installing system updates, applying configuration changes, or resolving performance and stability issues. Performing a safe reboot from the command line ensures that active processes are gracefully terminated, file systems are properly synced, and users are notified when necessary. This operation is particularly important in headless or remote environments where physical access to the server is limited or unavailable.

System administrators, DevOps engineers, and hosting providers commonly perform command-line reboots on Linux servers. This method is applicable across a wide range of environments, including dedicated servers, virtual private servers (VPS), and cloud-based instances. The command-line interface (CLI) offers flexibility and control, especially when managing servers via SSH or through automation tools.

Executing a safe reboot involves more than simply issuing a restart command. It requires checking for active users, ensuring all important services and data are properly saved, and optionally alerting users of the impending reboot. Failure to follow a safe reboot procedure can result in data corruption, service downtime, or user dissatisfaction. This guide outlines the recommended practices and commands to reboot a server safely through the CLI.

The article covers different reboot options, explains the role of various system commands like reboot, shutdown, and systemctl, and provides a structured approach to rebooting safely on systems running popular Linux distributions such as Ubuntu 22.04, CentOS 7, and Debian 11.

Prerequisites

  • A Linux server running a supported distribution (e.g., Ubuntu 22.04, CentOS 7, Debian 11)
  • Root or sudo privileges to execute system commands
  • SSH access or direct terminal access to the server
  • Awareness of critical services running on the server

 

Step-by-step Guide

Step 1: Check for Logged-in Users

Before rebooting, verify if other users are currently logged in to prevent interrupting active sessions:

who

Or to view detailed login sessions:

w

 

Step 2: Notify Logged-in Users (Optional but Recommended)

Use the wall command to notify all users of the upcoming reboot.

sudo wall "Server will reboot in 5 minutes for maintenance. Please save your work."

 

Step 3: Stop Critical Services Safely (Optional)

Stopping services like databases and web servers can help ensure data integrity.

sudo systemctl stop apache2
sudo systemctl stop mysql

Adjust service names based on what is running on the server.

Step 4: Reboot the Server Using a Safe Command

Several commands can be used to reboot the system safely. The most commonly recommended are:

Option A: Using reboot

sudo reboot

Option B: Using shutdown

sudo shutdown -r now

Option C: Using systemctl

sudo systemctl reboot

All three options achieve the same result on systemd-based systems, and they trigger a clean reboot sequence.

 

Step 6: Verify Server Is Back Online (Post-Reboot)

After a few minutes, verify that the server has rebooted and services have resumed.

ping your.server.ip
Or try reconnecting via SSH:
ssh user@your.server.ip
🖊️ Tip: Automate uptime checks with monitoring tools like UptimeRobot or Zabbix for production servers.

 

Conclusion

Rebooting a server safely from the command line involves more than issuing a restart command. It includes checking for logged-in users, optionally notifying them, stopping critical services, syncing file systems, and then using the appropriate reboot command. Following this approach reduces the risk of data loss, service disruption, and user impact.

For additional server management topics, consider exploring:

Should you have any inquiries about the guidelines, please feel free to open a ticket through your portal account or contact us at support@ipserverone.com. We’ll be happy to assist you further.