Are you trying to reboot or shutdown your Linux or CentOS server using the command line? Whether you’re making modifications to config files or are restarting the server to do some debugging, restarting a Linux from the command line should be a breeze.
There are many reasons why you might want to reboot your server, so in this blog post, I’m going to tell you how to do just that.
Ready? Let’s dive right into this tutorial…
On Linux, the shutdown and reboot commands can be executed via the command line, there’s several commands that you can run, they include:
I’ll teach you how to use these commands to restart your server. Up until this point, you might be familiar with just turning the machine off and on again, this is okay if you have a screen/monitor.
But more often than not, you’re remotely connected to the server without a screen or fancy interface.
Sometimes you need to restart a server if you’re doing upgrades or carrying out maintenance work.
The easiest and safest way to reboot a Linux server is to use the reboot command. To reboot the server gracefully and do it right now, run:
This command would attempt to stop and running services, and then attempt to reboot the server.
If running that command doesn’t work, you can forcefully reboot a Linux server using:
Although it’s recommended to reboot gracefully first.
The first of the commands is the shutdown command. It can be used to shut down the server, but can also be used to restart it.
In order to shutdown Linux, you’ll want to run:
shutdown -h now
-h flag is used to halt the server and the now param is used to shutdown the system right away.
If you wanted to reboot the server using the shutdown command, you’d run:
shutdown -r now
If you needed to schedule a reboot within the next 5 minutes, you would run:
shutdown -r +5
And what this is doing, is essentially saying to reboot the server within the next 5 minutes. Which would notify all users logged in the server, and also prevent new users from logging in.
You could specify any duration in minutes here.
Once you run this command and wanted to cancel the scheduled restart or shutdown, simply run:
Another option at your disposal is to use the halt command. Unlike reboot and shutdown, this command will halt the server. Although, the behaviour of this command may not be consistent across several servers.
Have you ever held the power button on your computer before to turn it off, well, the poweroff command is similar to the halt command, but is simply an alternative.
If you’re making changes to a server such as upgrading it or carrying out maintenance works, then you’ll likely need to reboot the server at some point.
Sometimes though, computers and servers can experience all kinds of glitches from simply being left on for long periods of time, and so a reboot could be a way of clearing out temporary files and is useful for debugging situations!
As a beginner, the shutdown and reboot commands are meant to be as simple and as effective as possible, so there shouldn’t be any troubles when trying to run these commands.
Of course though, just ensure that any changes have been saved before you restart the server. Or you’ll lose them!
As an e-commerce store owner, you understand the importance of having a reliable and efficient online presence. Let's look at why website uptime monitoring is so important for e-commerce. Read more today.Read more
As a business owner, ensuring customer satisfaction should be a top priority. One key aspect of customer satisfaction is having a reliable and efficient online presence, which is where website uptime monitoring comes in.Read more
As a website owner, uptime monitoring is crucial to ensure that your website is always available and functioning properly. In this article, we'll discuss how to maximize the efficiency of your website uptime monitoring strategy, including the use of tools, setting up alerts, and optimizing your website's performance.Read more
Looking to monitor your website and domains? Join our platform and start today.