Examples - Linux Shutdown Commands

December 5, 2012 | By
| Reply More

According to the manual page of shutdown command, Shutting down a system means bringing the system down in a secure way. How can you shut down your system successfully using a command? This article discusses the commands you can use to shut down your Linux box.

Shutting down your Linux

The simplest of the commands for shutdown is the shutdown command. The following examples show how this command can be used to bring down the system:

1. Shutdown Command

The format for shutdown command is

shutdown [OPTION]... TIME [MESSAGE]

The time can be given in 24 hour format HH:MM or +m, where m is the number of minutes to wait before shutting down the system.

• The system can be shut down immediately by providing "now" in place of time. For example

$ shutdown -h now

will bring down the system immediately.

• To shutdown the machine after given number of minutes, for example

$ shutdown -h +3

Broadcast message from root (pts/0) (Tue Nov 6 00:23:48 2012):

The system is going DOWN for system halt in 3 minutes!

• In 24 hour format,

$ shutdown -h 00:45

Broadcast message from root (pts/0) (Tue Nov 6 00:30:54 2012):

The system is going DOWN for system halt in 15 minutes!

• A custom message can also be provided

$ shutdown -h +5 "Save your work."

Broadcast message from root (pts/0) (Tue Nov 6 00:43:48 2012):

Save your work.
The system is going DOWN for system halt in 5 minutes!

• The shutdown command waits for command completion before giving back the prompt. So it can be cancelled with ctrl+c. Shutdown can also be cancelled with the -c option.

$ shutdown -c

2. Poweroff Command

Another command that can be used for bringing down the system is poweroff command

$ poweroff

Broadcast message from root (pts/0) (Tue Nov 6 09:39:17 2012):

The system is going down for system halt NOW!

3. Halt Command

The halt command will also shut down the system.

$ halt

Broadcast message from root (pts/0) (Tue Nov 6 09:42:43 2012):

The system is going down for system halt NOW!

4. Init Command

The init command is used to change the runlevel of the Unix/Linux system. These system runlevels are 0-6. The runlevel 0 is used for system halt. The following command will shut down the system:

$ init 0
INIT: Switching to runlevel: 0
INIT: Sending processes the TERM signal

Unlike other commands we have seen so far, the init command will not broadcast any message about system halt.

Filed Under : LINUX COMMANDS, LINUX HOWTO

Tagged With :

Free Linux Ebook to Download

Leave a Reply

Commenting Policy:
Promotion of your products ? Comment gets deleted.
All comments are subject to moderation.