6

halt can turn off the machine,

but shutdown now doesn't turn off ,it just logs the root off.

Anyone knows the reason?

yum
  • 569
  • 5
  • 9
  • 17

3 Answers3

7

On a modern Linux systems halt calls shutdown with a suitable argument -h (halt) or -r (reboot) these are the equivalent of runlevels 0 and 6. Running shutdown now puts the system into runlevel 1 (single user mode). If you want to halt the system with shutdown use shutdown -h now.

On Solaris 10/11 halt is quite brutal, it just flushes the disk caches and powers off the system - no attempt is made to run any scripts or shutdown smf facilities.

Other systems may do things differently too.

user9517
  • 115,471
  • 20
  • 215
  • 297
2

I assume Linux? (Good practice to tell or at least tag the OS).

'shutdown now' puts the system in init 1, while 'shutdown -h now' halts it 'now'.

From the manual of shutdown

shutdown does its job by signalling the init process, asking it to change the runlevel. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to put to system into a state where administrative tasks can be performed; this is the default if neither the -h or -r flag is given to shutdown. To see which actions are taken on halt or reboot see the appropriate entries for these runlevels in the file /etc/inittab.

3molo
  • 4,330
  • 5
  • 32
  • 46
0

thats a "long time ago" commands. shutdown or poweroff -- turnoff computer halt -- prepares computer to be shutted down after user push the power button.

MealstroM
  • 1,517
  • 1
  • 17
  • 32