HOWTO shutdown and reboot from the command-line

From LinuxReviews
Jump to navigationJump to search

Linux has several commands to turn of the computer.

The old-fashioned way[edit]

The old-school way of powering off a machine is to use the shutdown command. It takes several arguments. The most common is -h now to order a halt[1] NOW:

shutdown -h now

There's also two commands that do not need any arguments. These are halt and poweroff. These are actually symbolic links to systemctl on most modern machines.

'Rebooting can be also be done with the shutdown command by using the -r for reboot argument:

shutdown -r now

There is also a command called reboot which is actually a symbolic link to systemctrl on modern distributions.

These commands require you to be root which means you need to run them as root or use sudo.

The systemd way[edit]

systemd's control tool systemctl takes the following arguments[2]:

halt, poweroff, reboot, kexec, suspend, hibernate, hybrid-sleep, suspend-then-hibernate, default, rescue, emergency

systemctl does not require you to be root and will happily reboot or halt the machine when a user runs these commands. (unless the configuration file /etc/systemd/logind.conf is configured to prevent this, which it's not by default). As a normal user you can reboot by running:

systemctl reboot

and you can shutdown by running

systemctl poweroff

An interesting option to use with systemctl's reboot parameter is --firmware-setup which will take you directly to the machines BIOS ("firmware setup") upon reboot:

systemctl --firmware-setup reboot

notes[edit]