Linux shutdown

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

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:

shutdown <time>

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:

  1. shutdown now  

System will shutdown immediately.


Rebooting the system

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

Syntax:

shutdown -r <time>

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:

shutdown -h <time>

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:

shutdown -P <time> 

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:

shutdown <time> <"message">

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:

shutdown -H <time>

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:

shutdown -c 


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:

shutdown -k <time>

Example:

shutdown -k 3

Linux Shutdown7

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