Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Real difference between shutdown(8) and poweroff (8)



> what'is the real difference between:shutdown(8),
> poweroff(8),reboot(8) and halt(8) ?

The shutdown tool is setuid root and only executable by root or members of 
the operator group (so runs with root privilege). It can be used to set 
when a shutdown should happen. It runs in the background, logs about the 
shutdown, and sends shutdown messages to the terminals of current logins 
(using wall) warning when the shutdown will happen. If the shutdown time 
is within five minutes it creates a /etc/nologin file which is honored by 
login, sshd, and a PAM module to prevent new logins. Then shutdown runs 
the /etc/rc.shutdown script. Basically that script runs the rc.d scripts 
containing the "shutdown" keyword in reverse order with the "stop" command 
line argument. And then shutdown runs halt (or reboot).


The halt, reboot, and poweroff tools are just the same command. It will 
log to the wtmp and wtmpx login databases about the shutdown or reboot, do 
a sync so pending disk writes are completed, kill init, send a SIGTERM to 
all non-kernel processes, waits two seconds, does a sync again, waits 
three more seconds, sends an uncatchable SIGKILL to all processes (and 
retries that if needed a couple times), and then reboots the system or 
halts the processor(s).

Running poweroff will power off the hardware (on supported systems).

(I have more details in my NetBSD book in process.)


Home | Main Index | Thread Index | Old Index