shutdown

The shutdown command brings down system in a secure way. All the logged-in users are notified about the system shutdown.

Signal SIGTERM notifies all the processes that the system is going down, so that processes can be saved and exit properly.

Command shutdown signals the init process to change the runlevel.

Runlevel 0 halts the system

Runlevel 6 reboots the system

Runlevel 1 is default state.

Five minutes before shutdown sequence starts, file /etc/nologin is created when shutdown is scheduled for future which does not allow new user logins.

If by any reason, command shutdown is stopped before signalling init, this file is removed. It is also removed to change runlevel before signalling init.

To run shutdown command root user access is required.


Shutting down system

You can shutdown a system by passing a definite time (in minutes). System will automatically shutdown after specified minute giving a message and time to save all work.

Syntax:

Example:

shutdown 3

Linux Shutdown1

Look at the above snapshot, message is displayed on the terminal.

To immediately shutdown the system, use now option,

Syntax:

System will shutdown immediately.


Rebooting the system

With option r, system will shutdown immediately and automatically reboot.

Syntax:

Example:

shutdown -r 3

Linux Shutdown2

Look at the above snapshot, system will automatically reboot as shown in the message.


Power-off or halt-off the system

Option h decide whether the system will power-off or halt-off after shutting down.

Syntax:

Example:

shutdown -h 3

Linux Shutdown3

Look at the above snapshot, system decided to halt-off.


power-off the system

To power-off the system option P is used. You don't have to manually power-off your system, this option will automatically power-off your system.

Syntax:

Example:

shutdown -P 3

Linux Shutdown4

Printing a message during shutdown

Admin can convey a message to all the logged in users stating reason for sudden shutdown.

Syntax:

Example:

shutdown 3 "message"

Linux Shutdown5

Look at the above snapshot, admin message is displayed in the last line of output.


Halt-off the system

Option H is used to halt-off the system after system is brought down.

Syntax:

Example:

shutdown -H 3

Linux Shutdown6

Cancel shutdown

If due to any reason you want to cancel the shutdown command within the specified time, c option can be used.

Syntax:


Sending warnings and disabling logins

Option k will not halt or power-off the system, but just sends the warning and disable all the logins.

System will not actually shutdown.

Syntax:

Example:

shutdown -k 3

Linux Shutdown7

Look at the above snapshot, system only sends a warning and does not actually shut down.

Next TopicLinux info