Shutdown, reboot, halt, poweroff commands in Linux

Do not miss this exclusive book on Binary Tree Problems. Get it now for free.

In this article we have covered Linux commands that enable a user or system administrator to shutdown or reboot computer systems via the command line interface. We have also discussed how such operations can be scheduled i.e for system upgrades or maintenance.

Table of contents.

  1. Introduction.
  2. shutdown command.
  3. reboot, halt, poweroff commands.
  4. Summary.
  5. References.

Introduction.

Shutting down or rebooting systems can be done using pressing Ctrl+Alt+Del then choosing an appropriate action however the graphical user interface consumes alot of system resources as compared to the command line interface, furthermore scheduling such operations is easier using the terminal.

Here we cover four commands that perform the same actions however we will find that others are well suited to a certain task than others.

One should understand the terms shutdown, reboot, halt, hibernate, sleep, logout as a prerequisite.

Shutdown command.

This command is used to shutdown a device safely.

The syntax is as follows,

shutdown [OPTIONS...] [TIME] [MESSAGE...]

Commonly used options include,

  • -P, --poweroff, to poweroff the machine.
  • -r, --reboot, to reboot the machine.
  • -H, --halt, to halt the machine.
  • -c, to cancel a pending shutdown.

TIME specifies a time argument to schedule a reboot, or schedule a reboot after a certain period of time, or specify an exact time for an immediate shutdown.

The time format is as follows;

  • hh:mm, to schedule a specific time.
  • +m, to specify the number of minutes until shutdown.

MESSAGE argument is used to specify a message or instructions which will notify users.

To shutdown a system at 14:30 pm server/system time, we write,

shutdown 14:30

We can cancel this or any reboot or shutdown by writing,

shutdown -c

We can also cancel a shutdown with a message as follows,

shutdown -c "Cancelling shutdown"

To schedule a shutdown in the next 20 minutes, we write,

shutdown +20

To shutdown a system immediately we write,

shutdown +0

or we can also write,

shutdown now

To add a message we write,

shutdown +20 "Shutdown in 20 minutes for updates"

To reboot a machine we use the -r option with shutdown as follows,

shutdown -r +20

The command will reboot the machine in the next 20 minutes.

We can also schedule a reboot and add a message as follows,

shutdown -r 13:00 "Rebooting system at 13:00"

reboot, halt, poweroff commands.

The reboot command is used to reboot a system.

The syntax is as follows,

reboot [OPTIONS...]

To poweroff using reboot we write,

reboot -p

We can also force a reboot by using the -f option,

reboot -f

The halt command halts a system,

halt [OPTIONS...]

The poweroff command powers off the system,

poweroff [OPTIONS...]

Summary.

We have covered the shutdown command and various examples e.g shutting a computer down immediately, scheduling a shutdown, displaying shutdown messages and canceling a shutdown.

Alternatively one can press Ctrl+Alt+Del to shutdown, reboot or halt the system.
Assuming we scheduled a shutdown, five minutes before the system goes down, no new logins will be permitted, this is possible because of the /etc/nologin file which is created.

References.

  1. Execute the command shutdown --help or man shutdown for its manual pages.

Sign up for FREE 3 months of Amazon Music. YOU MUST NOT MISS.