‘Shutdown’ versus ‘poweroff’ versus ‘halt’ on Ubuntu server

There seems to be a lot of confusion around how to properly restart or shut down your server under Ubuntu. The are several commands out there: halt, shutdown, poweroff and reboot. Which are the right ones to use and what are the differences?

Historically, halt, poweroff and reboot were fairly low-level commands that would do exactly what their command name implies. However, they would not gracefully take down your server – it was presumed that the server administrator would do that him- or herself before invoking these commands. Many newer Linux users were not familiar with the right usage scenarios and, as a result, the commands were changed to invoke shutdown, a gentler command that gracefully terminates any open processes by giving them an opportunity to complete tasks before exiting.

Since these commands now invoke shutdown, the following are equivalent:

Restarting your server
reboot is the same as
shutdown -r 0

Turning off your server
halt is the same as
poweroff is the same as
shutdown -P 0

Note that these commands need to be invoked as root or via the sudo command, e.g.
sudo halt.

The original usage of these commands is also available via the -f switch. So to invoke halt directly without going through shutdown, use sudo halt -f. This is not recommended unless you are sure all other processes have finished their work. Similarly, sudo shutdown 0 by itself is not very useful – in Ubuntu it drops the server into the Recovery Menu since all processes are terminated but the server is not asked to power down or restart. It can certainly be manually powered down or restarted from there, though. Also, instead of the 0 after shutdown you can use now or specify some other time (either in minutes from now or absolute time) for the server to shut down.

  • Share/Bookmark

Comments (1)

  1. [...] sudo poweroff See also ‘Shutdown’ versus ‘poweroff’ versus ‘halt’ on Ubuntu server [...]

Leave a Reply