67

To turn off my system, I can use one of these three commands:

sudo halt

Or:

sudo poweroff

Or:

sudo shutdown -h now

What are the differences between these commands, or are they all just aliases of each other?

goldilocks
  • 87,661
  • 30
  • 204
  • 262
Will
  • 791
  • 3
    This question is marked as duplicate, but the "answers" just raise more questions - at least for those not intimate with the inner workings of Linux. On Raspbian which is still init based reboot and poweroff are links to halt. shutdown is different (the differences described in the answers). Ubuntu MATE for the Pi2 is systemd based and all 4 are links to /bin/systemctl – Milliways May 26 '15 at 00:36

1 Answers1

90

halt terminates all processes and shuts down the cpu.

poweroff is exactly like halt, but it also turns off the unit itself (lights and everything on a PC). It sends an ACPI command to the board, then to the PSU, to cut the power.

shutdown is like poweroff, but it also runs shutdown scripts which should stop things gracefully. Examples include giving programs a chance to close files, delete their lock files and unmount drives properly.

Sources:

https://serverfault.com/questions/191537/shutdown-what-is-difference-between-power-off-and-halt

http://osdir.com/ml/os.solaris.managers.summaries/2001-10/msg00027.html

A comment by Peter White

Aloha
  • 2,111
  • 1
  • 15
  • 22
  • But which one to use if you want to shutdown and poweroff a system remotely gracefully, giving programs a chance to close files, delete their lock files and unmount drives properly? – Peter White Jun 22 '21 at 12:17
  • I would use shutdown --poweroff for that. – Liam Sep 17 '21 at 19:53
  • 3
    This is out of date. See this answer for a more up to date answer: https://unix.stackexchange.com/a/196471/206286 – xordspar0 Sep 20 '21 at 14:28