The Wayback Machine - https://web.archive.org/web/20240205165922/https://www.geeksforgeeks.org/halt-command-in-linux-with-examples/
Open In App
Related Articles

halt command in Linux with examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

This command in Linux is used to instruct the hardware to stop all the CPU functions. Basically, it reboots or stops the system. If the system is in runlevel 0 or 6 or using the command with –force option, it results in rebooting of the system otherwise it results in shutdown.

Syntax:

halt [OPTION]...

Options:

Option Description
-f, –force It does not invoke shutdown.
-w, –wtmp-only It will not call shutdown or the reboot system call but writes the shutdown record to /var/log/wtmp file.
-p, –poweroff To behave as poweroff
–verbose Gives verbose messages when reebooting which helps in debugging problems with shutdown.

Files:

  • /var/log/wtmp : Consists a new runlevel record for the shutdown time.
  • /var/run/utmp : Gets updated by a shutdown time record when the current runlevel will be read.

Example 1: To cease all CPU function on the system.

$halt

Output:

Broadcast message from ubuntu@ubuntu
root@ubuntu:/var/log# (/dev/pts/0) at 10:15...
The system is going down for halt NOW.

Example 2: To power off the system using halt command.

$halt -p

Output:

Broadcast message from ubuntu@ubuntu
(/dev/pts/0) at 10:16...
The system is going down for power off NOW.

Example 3: halt command with -w option to write shutdown record.

$halt -w

Note: For this, there will be no output on the screen.

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 21 May, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials