In this tutorial, we will learn how to shut down and reboot our Linux system from the command line terminal, without the need to physically press the power button or use a GUI.
sudo
command to shut down or restart. It just depends on your Linux distribution’s configuration.poweroff Command
poweroff
is an old command, but still one of the most commonly used these days. To completely shut down your system, execute:
$ poweroff
reboot Command
The reboot
command is probably the quickest way to restart Linux, since it’s only a few keystrokes:
$ reboot
halt Command
You can also use the halt
command. This command kills all the proccesses on Linux, shutting down the system without actually powering it off, so it’s not very useful by itself.
The halt
command can shut down your system, like the poweroff
command, by using the -p
option:
$ halt -p
shutdown Command
The shutdown
command works similarly to poweroff
and reboot
, but also allows us to schedule a shutdown or reboot into the future.
To shut down your system:
$ shutdown now
To shut down and power off your system immediately:
$ shutdown -P now
To shut down and reboot your system immediately:
$ shutdown -r now
To specify when the system will shut down you can use the +m
format, where m
is the time, in minutes, that we can assign to schedule the shutdown.
$ shutdown +15
If you want to add a warning message, simply write it at the end of the command:
$ shutdown +15 'WARNING: The system is shutting down in 15 minutes.'
You can also schedule the time for the shutdown, using the 24 hour format.
$ shutdown 19:00
To cancel a scheduled shutdown, add the -c
option to the command:
$ shutdown -c
Using systemd
systemd is the essential software suite that manages a Linux system and its services. It’s on the majority of distributions, like Ubuntu, Fedora, etc. Its main tool, the systemctl
command, can be used to shut down and reboot our system. On top of that, we can use the systemctl
command to suspend or hibernate our system.
To shut down and power off the system:
$ systemctl poweroff
To restart the system:
$ systemctl reboot
To shut down the system (halt all processes) without powering off:
$ systemctl halt
To suspend the system:
$ systemctl suspend
To hibernate the system:
$ systemctl hibernate
To hybrid-sleep the system (acts like both the suspend and hibernate commands):
$ systemctl hybrid-sleep
To disable the message that systemd sends when using these commands, you can add the --no-wall
option:
$ systemctl --no-wall poweroff
Or:
$ systemctl --no-wall reboot