halt Command in Linux

This tutorial explains Linux “halt” command, options and its usage with examples.

halt command is used to stop the system.(requires root privileges)

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.

advertisement
advertisement

Hence the halt can also be used as

$ shutdown -h now

Synopsis :

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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.

advertisement

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.