Sunday, October 9, 2016

shutdown command

Linux PC can be shut down by using "shutdown" command.

# shutdown

By using options, shutdown command is used for a variety of purposes.

  • -h  : shut down PC
  • -r   : Restart PC after shut down
  • -f   : fsck[1] is skipped when PC is re-started
  • -F  : fsck is forced when PC is re-started
  • -k  : Send warning messages as if the shutdown is real but PC isn't shutdown actually.
  • -c  : Cancel a pending shutdown. (This does not apply to "shutdown now", which does not wait before shutting down.)


The following command shutdowns PC in 15 minutes and sends a warning message saying "please prepare for the shutdown in 15 minutes." But you need to be root to perform this command.

# shutdown -h +15 "please prepare for the shutdown in 15 minutes."

If you just want to send warning messages as if the shutdown is real, use -k option. But you need to be root to perform this command also.

# shutdown -k now "please prepare for the shutdown."

The following command shuts down the PC at 22:00.

# shutdown -h 22:00

The following command restarts the PC immediately.

# shutdown -r now

Once shutdown command is executed, users can't log in the system since then until the system is actually shut down and get restarted. The closer the planned time to be shutdown becomes, the more the users get warning messages.

[1] Linux fsck utility is used to check and repair Linux filesystems


References
Computer Hope http://www.computerhope.com/unix/ushutdow.htm Visited on 9th October 2016