New users are often surprised by the number of commands that can be used to shut down a Linux system. Thanks to the flexibility of Linux and its storied history, there is almost always more than one – or more than a few – ways to accomplish the same task. Although Linux is always giving users plenty of choices on how to operate their system, one method usually proves better for certain scenarios, and all come with their pros and cons.
The Linux commands used to shut down a system are no exception. There are plenty for the job, and some are more appropriate than others, depending on the situation. In this tutorial, we will go over all of the different commands used to shut down a Linux system, and explain the differences among each of them.
In this tutorial you will learn:
- How to shut down a Linux system with various commands
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Linux Shutdown Command History
There is a long sequence of events that took place to get Linux to where it is now, with all these overlapping shutdown commands. Linux took many conventions from Unix and BSD operating systems during its conception and in the years that followed, while also developing its own toolsets that often behaved similarly but had subtle differences.
Suffice it to say that these days, on most Linux systems, the majority of shutdown commands just do the same thing. Systemd is the init system for most contemporary Linux distributions, and handles the powering off of the computer. Most of the commands we go over below are just different ways of triggering the same mechanism within systemd which handles shutdown operations.
Someone, somewhere, has taken the time to map out the storied hisory of Linux shutdown commands, if you are interested. But what we should be most concerned about is how this applies to us today, and what commands we Linux administrators should be using to control our systems. This tutorial aims to do just that, as you will see in the command examples below.
Linux Shutdown Commands
Let’s look at the various commands used to shut down a Linux system, and how each of them work in the examples below.
On some systems, root access is required to shut down the system. This is something that is configured by default and can be edited by the user if they wish. Also note that some commands below may only work on certain Linux distributions.
- Perhaps the most common command to shut down a Linux system is the
shutdowncommand. To shut down your Linux computer, you can execute the following command:
$ shutdown -h now
shutdownby itself will cause the computer to turn off in one minute. If we want to shut down right away, the
shutdowncommand requires us to specify the
- If we want to shut down in 10 minutes, we can use the following syntax with the
$ shutdown -h +10
As you can see, the main advantage of using
shutdownis its ability to schedule shutdowns in the future.
- Another one of the most popular commands for shutting down a Linux system is the
poweroffcommand. This command will save you a few keystrokes versus the
shutdowncommand, so it is what many Linux administrators choose to use. It is a good command for whenever you need to immediately shut down the system.
- When a Linux system is shutting down, it changes into runlevel 0. Or, on systemd systems, target 0. This is further explained in our tutorial on How to check a current runlevel of your Linux system. We can switch directly into runlevel 0 (the shutdown runlevel) by typing the following command:
$ init 0
This is the equivalent of typing any immediate shutdown command and will power off the computer right away. Changing the runlevel is not a typical way to shut down the system for most users, but can be useful in Bash scripting or other niche scenarios where direct access to runlevels is required.
- Yet another way to shut down Linux is via the
haltcommand. On Systemd distributions, this is just another alias to trigger systemd to shut down the system, the same as it would with the other commands mentioned above.
- To reboot the system, we can simply use the
- In case we need to schedule a reboot, we can rely on the
shutdowncommand once more to supply this functionality.
$ shutdown -r +10
The previous command will perform a reboot in 10 minutes.
- Thanks to the convoluted history of shutdown Linux commands, we also have contradictory options built into some commands, such as:
$ poweroff --reboot
We do not recommend worrying about these confusing and unnecessary options.
In this tutorial, we learned about various shutdown commands that can be used on a Linux system. With all the different options, redundancy, and contradiction surrounding these commands, we think it is best to just keep it simple: use the
shutdowncommand for all of your powering off, rebooting, and scheduling needs. To save keystrokes, or if you find them easier to remember, the
rebootcommands also come in handy. Everything else is just a distraction.