Cloud Service >> Knowledgebase >> General >> How to Reboot a Linux Server via SSH?
submit query

Cut Hosting Costs! Submit Query Today!

How to Reboot a Linux Server via SSH?

Server administration is all about efficiency and reliability. Whether you are in charge of a single server or the whole network infrastructure, remote management is a crucial aspect of operating smoothly. Rebooting a Linux server is a critical job. It can be done only after proper planning and execution; otherwise, service continuity might be disturbed and cause downtime.

Leveraging SSH (Secure Shell) and rebooting a Linux server becomes a streamlined process. It empowers administrators to initiate system restarts with precision and confidence.

In this guide, we journeyed through the intricacies of rebooting Linux servers via SSH. 

Understanding SSH

SSH is a cryptographic network protocol that transfers encrypted data between two computers. It transmits data safely and securely over an insecure channel. Thus, administrators can access and manage servers remotely with a command-line interface.

Prerequisites

Before rebooting a Linux server via SSH, ensure the following:

SSH Access

You must have SSH access to the Linux server. This typically involves knowing the server's IP address or domain name and having valid authentication credentials (username and password or SSH keys).

Administrator Privileges 

Ensure you have administrative privileges or sudo access on the server to execute commands requiring elevated permissions.

Understanding Consequences

Rebooting a server will interrupt any ongoing processes and temporarily disconnect users. To minimize disruption to services, plan the reboot during a maintenance window.

Steps to Reboot a Linux Server via SSH

Connect to the Server

Launch a terminal or SSH client on your local machine. Use the following command to connect to the Linux server:

ssh username@server_ip

Enter your username on the server, and instead of server_ip, mention the IP address or domain name of the Linux server.

Authenticate

Enter your password or provide the SSH key passphrase if you receive the prompt to authenticate the connection.

Issue Reboot Command

Once logged in, issue the reboot command to initiate the server reboot. You can do this by typing:

sudo reboot

If prompted, enter your password or confirm the reboot command.

Wait for Reboot

The server will begin the reboot process. Wait a couple of seconds for the server to turn off and then boot.

Reconnect

After the server reboots, you must wait a minute or two for a complete online return.

Once it's ready, you can reconnect using SSH:

ssh username@server_ip

This should enable you to log in to the server as usual.

Additional Considerations

Graceful Shutdown

Before rebooting the system, you should shut down the ongoing services carefully to prevent data loss or corruption. sudo service stop is one of the commands you can use to shut down specific services.

Emergency Reboot

Sometimes, you may encounter issues requiring an immediate server reboot. In such situations, you can force a reboot using the -f option with the reboot command: 

sudo reboot -f

However, this should only be used as a last resort, as can result in data loss or file system corruption.

Monitoring Reboot Progress

If you're rebooting a critical server, consider using tools like ping or monitoring services to track its availability during the reboot.

Automating Reboots

For routine maintenance tasks, you can automate server reboots using tools like cron jobs or scheduling tasks with utilities like at or systemd.

To Sum it Up!

SSH rebooting a Linux server by a system admin is fundamental for any sys admin. You can safely and effectively perform a remote reboot of the Linux server that you have just shut down by following the steps outlined in this guide and by considering other best practices that will minimize downtime and ensure that the functionality of your infrastructure is optimal. While starting over can be liberating, maintain caution and plan shutdowns thoughtfully, especially production infrastructures, to avoid unforeseen impact and service disruptions.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!