Section 14.4. Stopping Linux


[Page 580]

14.4. Stopping Linux

No computer can be turned off the way you turn off other electrical appliances. A Linux computer has running processes and open files, and a sudden loss of power can cause problems in the file system or even hardware failures. You should always gracefully shut down a Linux system.

The traditional way to stop a Linux system is to change the run level to 0 (halt). To reboot, change the run level to 6. This can be done on a Linux system with the init and/or telinit commands.

However, a more graceful method to stop a Linux system is to use the shutdown utility (Figure 14-2). shutdown can be used to either halt Linux, place it into single-user mode (run level 1), or place it into multi-user mode. It allows the shutdown or reboot to be scheduled at some point in the future and it emits warning messages prior to the shutdown so that users may log out before the system changes state.

Figure 14-2. Description of the shutdown command.

Utility: shutdown -hkr time [ message ]

shutdown shuts down the system in a graceful way. The shutdown time must be specified in one of three ways:

  • now: the system is shut down immediately.

  • +minutes: the system is shut down in the specified number of minutes.

  • hours:minutes: the system is shut down at the specified time (24-hour format).

The specified warning message (or a default one if none is specified) is displayed periodically as the time of shutdown approaches. Logins are disabled five minutes prior to shutdown.

If neither -h nor -k is specified, shutdown brings the system down to single-user mode by signaling init to change to run level 1. Using the -h option causes shutdown to change the run level to 0 (halt). The -r option causes shutdown to change the run level to 6 (reboot). The -k option is funny; it causes shutdown to behave as if were going to shut down the system, but when the shutdown time arrives, it does nothing. The "k" stands for "just kidding"!





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net