What is the difference between halt, poweroff and reboot?

6

I've heard several times that if I want to shut down / restart the computer through the terminal, just do one of the following:

  • halt
  • poweroff
  • reboot

poweroff and reboot are very intuitive "off" and "restart", I just did not understand halt "stop"

To which I was told:

  

"The computer has startup stages halt sends to stage 0"

I also learned that it has 6 stages.

From the terminal documentation I have not had much success in knowing what they are:

> man halt
...
DESCRIPTION
       halt, poweroff, reboot may be used to halt, power-off or reboot the machine.
...

Doubt

  • What actually is halt ?
  • What are his stages?
asked by anonymous 19.07.2017 / 15:30

1 answer

7
  

What is halt really?

Halt is a command for all CPUs present in the system.

  

What stages of it?

The boot stages are 6, as you said, which are as follows:

  • BIOS - runs some system integrity checks, looks for the boot program, loads it into memory and gives it control
  • MBR (Master Boot Record) - Basically loads and runs GRUB (Grand Unified Bootloader)
  • GRUB - It is the screen that shows the systems that can be started. It waits a few seconds for a selection, if it does not, it loads the default system
  • Kernel - Mount the filesystem, run the / sbin / init program
  • Init - Look in / etc / inittab to decide the RunLevel system, which are these here:
    0 - Halt (this is where the Halt command puts you)
    1 - Single User Mode
    2 - Full Multiuser mode
    3 - unused
    4 - X11
    5 - reboot
  • Runlevel Programs - this is where services and programs are started
  • I put the startup stages and the stages of RunLevel, so there is no confusion. The "0" stage that halt puts you in is RunLevel

    More specs on the Halt command

    • If you invoke halt without parameters, it simply executes shutdown
    • If called with - force , during runlevel 0 or 6, it runs reboot , otherwise it runs shutdown
    • If called with -p , it behaves like poweroff
    • If called with -w , it does not reboot nor poweroff . Instead, it writes the shutdown log to / var / log / wtmp .
    • If called with - verbose , it shows more detailed messages in reboot, useful for debugging problems with shutdown

    References

    link
    link

        
    19.07.2017 / 16:36