18

I'd like to know what the difference is between shutdown -H (halt the machine) and shutdown -P (poweroff the machine). I understand what poweroff means; it's rather self-explanatory. But what exactly is "halt"?

Background: I need to turn off my PC with a terminal-command because otherwise the shutdown/reboot hangs.

I found the command shutdown -H -P +0 here. It seems to be combination of the two options and it really works fine.

P.S. I have Lubuntu 18.04.2, 64 bit

3
  • 1
    Why not try and find the source of the shutdown/reboot problem? When it hangs, try hitting the ESC key and see if it brings up a text log of the shutdown/reboot process. Look at any FAIL entries, or the last few entries, for a clue.
    – heynnema
    Mar 20, 2019 at 13:34
  • 1
    @ heynnema: It´s a bit difficult. Some other people experience the same problem. Shutdown/reboot hangs at a certain point: "kvm: exiting hardware virtualization". See also: unix.stackexchange.com/questions/188747/… . The easiest way turns out to be "poweroff".
    – Rosika
    Mar 20, 2019 at 15:39
  • 1
    @sudodus Thanks for posting an answer. You should probably delete your comment now.
    – wizzwizz4
    Mar 20, 2019 at 19:54

2 Answers 2

17

Make it easy and use the command

poweroff

It works with my Lubuntu 18.04 LTS.

halt means flush buffers, unmount drives, close all processes in a graceful way. But not power off (though some systems may power off anyway). So the hardware is still provided with power.

After halt a hard power off (pressing the power button or unplugging the power supply) will not damage the system, because it is already halted in a graceful way.

2
11

From the man page of shutdown:

-H

Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system

Halted here means it is going to wait for a user action. That can be pressing the power down button and holding it to stop the machine. But also pressing a key that would restart the machine. That can be useful if you want to enter BIOS of the machine.

-P

Requests that the system be powered off after it has been brought down.

+0

it the time it has to wait in minutes

So... -P can, depending on the system, already be part of the -H option. You need the -P if the -H does not power down by itself. What actually happens is part of ACPI and the implementation of it can be buggy so for some it works for others not so ... The general idea when giving a solution is to try to cover all the bases and that would be to use both: -H and -P.

1
  • 8
    Recall that older computers (without ACPI) couldn't turn themselves off. Witness Windows 95's "It is now safe to turn off your computer" screen. Mar 20, 2019 at 16:22

Not the answer you're looking for? Browse other questions tagged .