Restart your Linux Server — Commands to reboot via SSH

Restart your Linux Server — Commands to reboot via SSH

abtract computer console

As a sysadmin, one of the things you’ll need to do sooner than later is reboot a server via SSH.  Even though it’s easy to do once you figure out how, it’s importance makes it worth learning about. This operation can be essential for maintaining your server’s performance and reliability, assisting you in recovering from a variety of issues including software crashes or even configuration modifications that only take effect after a reboot. In this blog post, we’ll go over a few different SSH server restart techniques as well as offer some helpful advice and information to get you started.

TL;DR

The most commonly used restart command in Linux is simply “reboot”, or “sudo reboot” if you are not logged in as root. This will immediately begin the process of restarting the server, provided you have permissions to run the command. More advanced options are also available.

Restarting a Server via SSH:

To restart a server using SSH, you’ll need to connect to it first. You can do this with any SSH client such as PuTTY. Just login to the server’s hostname or IP, using your username and password. The account you login with should have administrative or root privileges, or you can “sudo” to gain those privileges.

After you’ve logged in, the simplest way to restart a server, is simply with the command “reboot”:

reboot

As mentioned before, this will only work if you have the necessary permissions. Ordinarily this requires you login in as root, or a user that’s been given root privileges. Keep in mind that the “reboot” command will reboot the server right away, by telling all processes to gracefully save their work and exit.

What other options are there?

Beyond the simple “reboot” command, there are several other ways to restart a server while connected to SSH. For example, you might use these if you want to reboot or shutdown the server at a scheduled time. The relevant commands include shutdown, init, and systemctl.

Now let’s look at the shutdown command. With this command it’s possible to schedule a shutdown or restart for a future time, and you can choose between shutting down or restarting the server. To immediately reboot the server (much like with the reboot command), the following options can be used with “shutdown”:

shutdown -r now

Next, let’s look at the init command. This command can be used to shut down and restart the server, as well as to perform other tasks related to the initialization process. Again, to behave the same way as the “reboot” command, the following example uses init to reboot the server immediately:

init 6

Finally, let’s consider the systemctl command. systemctl is commonly used to start, stop, or restart different system services, but it can also be used to reboot the server entirely. Again, to immediately reboot the server the same way the “reboot” command does, you can use systemctl as follows:

systemctl reboot

If you want to use some of the more advanced features of these commands, such as scheduling, we suggest reading the “man” page for the command you’re interested in. Linux man pages can be opened by typing “man” before the command, such as:

man shutdown

Conclusion:

In this article, we covered how to restart a server via SSH. We hope you learnt something new. Although it can appear to be a straightforward task, there are still nuances that even experienced server administrators can benefit from knowing. You can be better equipped to deal with any issues that might emerge with your server by studying the various techniques and commands that can be used to restart a server via SSH.

Do you love servers?

We do! If you have questions related to Linux and servers, large or small, IOFLOOD can help. Our dedicated servers offer a range of solutions to fit your needs, and our team of experts is always available to provide support and guidance for all your server-related questions.

To learn more about our dedicated servers and how we can help you with your specific needs, contact us at sales[at]ioflood.com or visit our website at https://ioflood.com. Our team is ready to answer your questions and help you find the best server for your needs.