5 Ways to Shut Down Your Linux Computer From the Command Line

Christian Cawley 12-05-2017

No operating system is perfect. Even if it was, there might be problems with drivers and apps. Linux is no exception. Despite being more stable than Windows (in many cases, not all!), there will probably come a time when you need to restart your Linux computer. This might be because something isn’t working. Alternatively, you might be connected via SSH to a remote computer How to Remotely Manage a Linux Server with SSH SSH is very functional, which is why it's a go-to for remote server management. Learn how to remotely manage a Linux server via SSH, from connection, to installing software, and file transfers. Read More or server and want it to restart or shut-down completely.


But how might you do this? Several commands are available for you to power off or restart (or reboot) a Linux computer via the command line.

Let’s look at them in turn, and examine how and when these commands should be used.

1. Shutdown

If you’re done with your Linux box, the solution to simply shut it down is to use the shutdown instruction, sent via SSH (if you’re using a Windows PC, you have several SSH tools How to Use SSH in Windows: 5 Easy Ways SSH is an encrypted network protocol used for remote access. Here's how to use SSH in Windows using native and third-party apps. Read More to choose from). This can be used to either shut the computer off permanently (until such a time as you decide to reboot it) or to restart. The syntax for the command is:

shutdown [option] [time] [message]

For instance, to shut the computer down immediately, you would use:

shutdown -h now

linux terminal shutdown commands restart


Here, the -h means halt while now clearly means that the instruction should be carried out immediately. Different delays can be used. For instance, you might use +5 instead, which will tell the computer to run the shutdown procedure in five minutes.

If you want to include a message, this will be flashed up to all logged in users:

shutdown -h +5 "The server is shutting down, please save your work and log off."

Remember that you can find the full list of switches for these commands by inputting:

[command] --help

linux terminal shutdown commands help


Restart With -r

An alternative option is to use the -r command to restart the computer. This is used in place of the -h, so to restart a computer or server, you might use:

shutdown -r +5 "The server is restarting in five minutes, please save your work and log off."

Any scheduled shutdown or restart can be cancelled by inputting the -c cancel command:

shutdown -c

2. Reboot

As the shutdown command features a restart option, it should come as no surprise to learn that the reboot command has a shutdown option.

linux terminal shutdown commands screen
Image Credit: Anton Khegay via Shutterstock


The standard reboot command is:


This will prompt your computer to turn itself off, and back on again. However, should you wish to power off the device, then the -p switch will work:

reboot -p

Another option is to force a reboot. This can be useful if an app or service is hanging and you need to restart quickly:

reboot -f

This forcefully reboots your Linux box.


3. Halt

We’ve already seen the -h switch above, but halt can be used as a command all on its own. This will lead to the computer shutting down immediately, with a simple four letter word:


The -f switch can also be used with halt, but the results are inconsistent, and can lead to system stability issues.

4. Poweroff

You might prefer the terminology of the poweroff command. This does exactly the same as halt, except it takes over twice as long to type.

However, as well as using -f to force poweroff, you can also employ the -w switch to log the system reboot call to /var/log/wtmp. This is a potentially useful debugging tool, as is –verbose, which can help with issues with shutdown.

poweroff --verbose

5. The Emergency Option: REISUB

All of the above commands can be used in situations when the system is running without any problems. But what if it crashes? What if the PC or server is hanging, and cannot be rebooted in the agreeable manner?

The answer then is a keyboard combination. If you’ve switched from Windows, you probably know that Ctrl + Alt + Del displays a menu with Shutdown as an option. If held for longer, the machine will shut down automatically. On a Mac, meanwhile, you would simply hold down the power button (an option that also works on Windows hardware).

linux terminal shutdown commands keyboard
Image Credit: JanHetman via Shutterstock

In Linux, the keyboard combination is Alt + Print Screen + B to reboot. However, if this doesn’t work, or there is a more complex issue, you can alter the combination, using up to six keys.

This is known as REISUB, due to the following forced acronym:

  • unRaw — Takes control of the keyboard back from the X display server.
  • tErminate — Sends the termination signal SIGTERM to all processes, to terminate gracefully.
  • kIll — As above, but the SIGKILL signal, which forces immediate termination to processes.
  • Sync — Flushes data to disk.
  • Unmount — This remounts all filesystems into a read-only state.
  • reBoot — As you’d expect.

To make this work, you should hold down Alt + Print Screen, then the R E I S U B keys in that order. Leave a second or two between each keypress. Note that this method doesn’t typically work on machines with ARM architecture (such as the Raspberry Pi Raspberry Pi - A Credit-Card Sized ARM Computer - Yours For Only $25 Something big has been brewing in the university town of Cambridge, UK. For the past year a team of academics, businessmen, lecturers and programmers have been making final amendments to a very exciting project indeed.... Read More ).

Help, I Accidentally Shut Down My Linux PC or Server!

We’ve seen how to cancel a shutdown or restart command. However, it’s easy to find yourself initiating a shutdown command when a vital process is running — especially on a remote server. A way around this is to install molly-guard, which can override a shutdown by checking for certain parameters.

For instance, there is a script that checks for SSH sessions (which are different from FTP What SSH Is & How It's Different From FTP [Technology Explained] Read More ). If you send a reboot, halt, poweroff, or shutdown command, molly-guard will demand the name of the host you intend to close.

linux terminal shutdown commands molly

To use this, install molly-guard in the terminal:

sudo apt-get install molly-guard

As molly-guard is running in the background, it will detect a command such as poweroff and report back that an SSH session has been detected. You then have the choice of entering the server’s hostname to confirm shutdown, or to press Ctrl + C to cancel. Useful!

Those five ways of shutting down a Linux computer from the command line are particularly useful as they can be used on the computer itself, or via a remote SSH. As these commands are so concise, they lend themselves to quick use — which might result in an accidental reboot from time to time! Fortunately, the molly-guard utility is enough to avoid this.

To learn more Linux commands The Linux Commands Reference Cheat Sheet This simple cheat sheet will help you get comfortable with the Linux command line terminal in no time. Read More , check out our reference cheat sheet. And if you want to automate any of these commands, check out these automation apps for Linux 4 Linux Automation Apps to Streamline Your Tasks and Workflows Want to save time and avoid repetitive tasks? The answer is automation! Here are some useful Linux desktop automation apps to try. Read More .

Related topics: Linux, Terminal.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Starcy
    May 14, 2017 at 9:29 am

    What about "init 0"?

    • Christian Cawley
      May 15, 2017 at 9:01 pm

      It's a fine suggestion! For my part, There's not much difference in time taken between that and poweroff, but I felt bringing UNIX into the article might be distracting for Linux newbs.

  2. William Vasquez
    May 13, 2017 at 2:50 am

    I always thought it was CTRL + ALT+PRINT SCREEN (or SySRq) and then REISUB, not REIBUS. I was told an easy way to remember is REISUB is the word BUSIER spelled backwards. Unless that was a typo you printed in your column.

    • Christian Cawley
      May 13, 2017 at 11:06 pm

      Oh good spot, thanks.