SHUTDOWN(8)

NAME
shutdown - close down the system

SYNOPSIS
shutdown [ -h | -r ] [ -fqs ] [ now | hh:ss | +mins ] [ message ]
reboot [ -h | -r ] [ -fqs ] [ now | hh:ss | +mins ] [ message ]
fastboot [ -h | -r ] [ -fqs ] [ now | hh:ss | +mins ] [ message ]
halt [ -h | -r ] [ -fqs ] [ now | hh:ss | +mins ] [ message ]
fasthalt [ -h | -r ] [ -fqs ] [ now | hh:ss | +mins ] [ message ]

DESCRIPTION
In general, shutdown prepares the system for a power down or reboot. A absolute or delta time can be given, and periodic messages will be sent to all users warning of the shutdown. If no message is specified on the command line, shutdown will ask for a message to be sent, unless the -q option is set or a default message is specified in the file /etc/shutdown.conf (see below). halt is the same as shutdown -h -q now fasthalt is the same as shutdown -h -q -f now reboot is the same as shutdown -r -q now fastboot is the same as shutdown -r -q -f now The default delta time, if none is specified, is 2 minutes. Five minutes before shutdown (or immediately, if shutdown is less than five minutes away), the /etc/nologin file is created with a message stating that the system is going down and that logins are no longer permitted. The login (1) program will not allow non-superusers to login during this period. A message will be sent to all users at this time. When the shutdown time arrives, shutdown notifies all users, tells init(8) not to spawn more getty(8)'s, writes the shutdown time into the /var/log/wtmp file and terminates all processes as follows: It kills (SIGTERM) all non-privileged (uid>=1000) processes on the system, executes finalprog as specified in /etc/inittab (see init(8) ) with the argument "stop", tells init(8) with a SIGTERM signal to kill it's getty(8)'s, calls initctl(8) -r -f to stop services started during bootup, kills (SIGTERM) all remaining processes, waits 2 seconds (default may be changed in /etc/shutdown.conf ), and terminates any remaining processes by force (SIGKILL). After all processes have been terminated the /etc/nologin file is deleted and shutdown(8) tells init(8) with a SIGQUIT signal to exec /sbin/shutdown (which detects PID==1 and pauses forever). That way / can be cleanly unmounted even if init(8)'s old inode has been unlinked. Finally, shutdown(8) sync(2)'s, turns off swapping, unmounts all the disks, sync(2)'s again, waits for a second, and then either reboots or halts the system. For the latter case a program may be configured in /etc/shutdown.conf (see below) that will be called to turn off the power supply.

OPTIONS

-h  Halt the system. Do not reboot. This option is used when powering down the system.

-r  Reboot the system.

-f  Fast. When the system is rebooted, the file systems will not be checked. This is arranged by creating /fastboot, which /etc/rc must detect (and delete).

-q  Quiet. This uses a default broadcast message, and does not prompt the user for one.

-s  Reboot in single user mode. This is arranged by creating /etc/singleboot, which simpleinit(8) detects (and deletes).

FILES
/etc/rc
/fastboot
/etc/singleboot
/etc/nologin
/var/log/wtmp
/etc/shutdown.conf

CONFIG
The configuration file /etc/shutdown.conf is used to configure several aspects of shutdown(8)'s behaviour. Every line starts with a keyword (case-insensitive), followed by an optional = sign and one or more parameters. Lines beginning with # are comments and will be ignored. Here is an example /etc/shutdown.conf file
    #This is an example /etc/shutdown.conf
    default_message=Goodbye. Have a nice shutdown :-)
    halt_action  =  /sbin/mdstop -a
    kill_delay   =  5
default_message specifies the message that users will get if none is specified on the command line. kill_delay specifies the delay between sending SIGTERM and SIGKILL to processes. halt_action specifies the action you wish to take on halt. The options allowed are:

halt
    This will simply halt the system. This is the default behaviour. Note also that this is the fallback if another option fails.

power_off
    This will use the kernel power shutdown facility. This is usually only available on machines with Advanced Power Management (APM).

programname arguments
    This specifies a command to run to shut down the power. The first character must be a "/". Bear in mind that this command will be run with only the root filesystem mounted (and it will be read-only), and no daemons running. Any arguments following programname will be passed to the program. To specify arguments which contain spaces you must enclose them in quotes "...". Within the quotes you can use the backslash \ to escape any embedded quotes or backslashes.

SEE ALSO
umount(8), login(1), reboot(2), simpleinit(8), init(8) initctl(8)

BUGS
Unlike the BSD shutdown, users are notified of shutdown only once or twice, instead of many times, and at shorter and shorter intervals as "apocalypse approaches." Some would construe this as a feature. If shutdown is executed by init (as ctrlaltdel program), the finalprog program is executed without stdin/stdout/stderr. This means that unless it takes special measurements it will not be able to do input or output. shutdown(8) makes use of the system(3) function in several places which executes functions through the default shell which might be subject to manipulation through the setting of environment parameters. You should not make shutdown(8) suid/sgid root or execute it from suid/sgid programs unless those make sure that the environment is clean and the shell being executed by system(3) is what you think it is. If ordinary users need the ability to shut down or reboot the system you can make init(8) execute shutdown(8) when Ctrl-Alt-Del is pressed. This is safe because shutdown will be executed in the context of init, not the user's.

AUTHOR
This page documents the version of shutdown originally written by Peter Orbaek (poe@daimi.aau.dk). It was modified by Matthias Benkmann <m.s.b@gmx.net>. Contact me about any problems with this version.