Linux - shutdown

linux

How can we cancel a pending shutdown?

shutdown -c

What are the command line options for the shutdown command?

On System V:

shutdown -g n [-i level][-y]
  1. n is the number of seconds to wait before beginning the shutdown process. The message is broadcast to all the users that are currently connected, but the actual shutdown process is started after this specified number of seconds.
  2. level:
    • 0: turn of the power
    • 1: administrative state
    • s: single user mode (this is the default if -i is omitted)
    • s: firmware
    • 6: reboot to initdefault
shutdown -g120 -i6 -y

On BSD:

shutdown [option] time message

where time is:

  • +m: shutdown in m minutes
  • h:m: shutdown at the specified time (24-hour clock)
  • now: begin shutdown now
shutdown +60 "System is going down for regular maintenance"
shutdown -h -t 5 now // 5 is the duration between TERM signal and KILL signal
shutdown -r +5 "System is going down for maintenance" // shutdown and reboot
shutdown -f // request a fast reboot

How should we reboot from single user mode?

  1. CTRL+D: Returns to multi-user mode by continuing the boot process.
  2. shutdown: We can use the shutdown command as normal. This halt the system, then reboot, and check disk.
  3. reboot: reboots the system, bypassing the normal activities.

What is the purpose of the /etc/shutdown.allow file?

If exists and not empty, then its content control who is allowed to shutdown the system. Lines in this file is of the form:

hostname username

Example /etc/shutdown.allow file:

hamlet    chavez    // Allow chavez to shutdown hamlet
+    harvey    // Allow harvey to shutdown any system
eden    +    // Allow any user to shutdown host eden

The shutdown.allow file also support the percent sign as an additional wild card character denoting all system within a cluster.

On Linux system, shutdown does not need to be initiated by one of these users listed in shutdown.allow. If one of them is logged into a session controlled by the console, any other ordinary user can shutdown the system via CTRL+ALT+DELETE (ctrlaltdel)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License