How To Reboot A Linux Server using the command line [Beginner's Tutorial]
# tutorial# how to

How To Reboot A Linux Server using the command line [Beginner's Tutorial]

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…

Linux/CentOS Shutdown / Reboot Command

On Linux, the shutdown and reboot commands can be executed via the command line, there’s several commands that you can run, they include:

  • reboot
  • shutdown
  • half
  • poweroff

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.

Linux "reboot" command

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:

reboot

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:

reboot -f

Although it’s recommended to reboot gracefully first.

Linux "shutdown" command

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

The -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:

shutdown -c

Linux "halt" command

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.

Run:

halt

Linux "poweroff" command

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.

poweroff

Why might you want to reboot a Linux server?

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!

Conclusion

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!

More posts

Introducing Two-Factor Authentication [Plus Additional Security Features]

We're pleased to announce that you can now enabled Two-Factor Authentication (2FA) in your Domain Monitor account. Enable it today to take advantage of additional account security.

Read more
Setting Your Time Zone [New Feature]

Time Zones, they're a pain. Recently, here in the UK the clocks have gone forward, and for many of you, you’ve probably forgotten a few clocks or watches around the house right?

Read more
Introducing Slack Notifications [Third-party Integration]

I'm pleased to announce that we've just launched our Slack Integration as a new Notification Type, and you can enable it today!

Read more

Get our FREE downloadable PDF revealing The Top 3 Benefits Of A Website Monitoring Tool!

Plus, more great content, product news and updates