This tutorial explains Linux “halt” command, options and its usage with examples.
Description:
halt command logs in the file /var/log/wtmp, and then either tells the kernel to halt. If halt is called when the system is not in runlevel 0 , in other words when it’s running normally, shutdown will be invoked instead (with the -h flag), which kills most system processes but does not actually halt the system; it still allows the administrator to remain logged in as root.
Once system processes have been killed and filesystems have been unmounted, the system halts/powers off automatically. This is done using the halt command, which syncs changes to disks and then performs the actual halt/power off.
On Linux, if halt or reboot is run when the system has not already started the shutdown process, it will invoke the shutdown command automatically rather than directly performing its intended action. However, on systems such as FreeBSD, these commands first log the action in wtmp and then will immediately perform the halt/reboot themselves, without first killing processes or unmounting filesystems.
Hence the halt can also be used as
$ shutdown -h now
Synopsis :
halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]
OR
halt [-l] [-n] [-q] [-y]
Options :
-d
Don’t write the wtmp record. The -n flag implies -d.
-h
Put all harddrives on the system in standby mode just before halt or poweroff.
-p
When halting the system, do a poweroff. This is the default when halt is called as poweroff.
-q
Quick halt. No graceful shutdown is attempted.
-f
Force halt or reboot, don’t call shutdown.
-y
Halt the system, even from a dialup terminal.
-w
Don’t actually reboot or halt but only write the wtmp record (in the /var/log/wtmp file).
-i
Shut down all network interfaces just before halt or reboot.
-l
Suppress sending a message to the system log daemon, syslogd, about who executed halt .
-n
Prevent the sync before reboot or halt.
For example :
$ halt -f
This command halts the system immediately without invoking shutdown.
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Apply for Programming Internship
- Check Information Technology Books
- Practice Programming MCQs
- Check Linux Books