Shutdown

From LQWiki
Jump to navigation Jump to search

shutdown is one of the UNIX commands used to change the runlevel of a system, or to either reboot or halt the system. In most Linux distributions, the famous Ctrl+Alt+Del key sequence executes variations on shutdown -r now. Most traditional Unixes don't do this. This setting is configured in /etc/inittab.

Tips

  • to shut down your computer immediately, if you have the proper permissions, use:
shutdown -h now
  • to simply reboot the machine (if you have a problem with the reboot command, use:
shutdown -r now
  • to cancel an already initiated shutdown, you can use:
shutdown -c optional message to users
  • to kid, not to undergo a shutdown, just to broadcast message to the users as if the system is going down:
shutdown -k optional message to users

If you're the only user of your system, the now option is fine. However, if you're on a multi-user system, it is customary to give the users about five minutes or so to save their work, and a warning message about why the system is going down. You can specify the delay before shutdown or reboot by replacing the word now with a number, which will be the time in seconds before your command executes.

  • If you want to skip the filesystem check on boot, which is done normally by the program fsck, then add the f option to options h or r such as:
shutdown -hf now

or

shutdown -rf now

Unless you are in a hurry, the f option is not recommended.

  • If you want to force the normal filesystem check by the fsck command, then use the F option the same way as above.


See your system's man pages for more options about how your system implements this command.

Personal Workstations

To allow normal users to shutdown a PC, use the sudo utility, or setup a wheel group, and add a user to it.

  # sudo /sbin/halt
     -or-
  # sudo /sbin/shutdown -h now

Power management systems like ACPI and APM can be used to automatically power off a PC upon shutdown. For example, one can edit /etc/rd.d/modules and append the following option to the apm module:

  /etc/rd.d/modules:
  apm power_off=1

Permissions Note

On Xubuntu Linux as of 18.04, it is common that all users can invoke these commands, and their /sbin, /usr/sbin, and /usr/local/sbin directories are in their $PATH because of the default contents of /etc/environment. This may be true of other variants and releases as well.

See Also