-->
Page 44
Both of these are manual approaches. But since the Red Hat folks have taken such great pains to make system administration easier, why not take advantage of point-and-click convenience? When you use tksysv, you can see at one glance which processes are going to be enabled or disabled at each runlevel.
The tksysv client, written in tcl/tk, is a runlevel editor. You simply select a service and then click the Add or Remove button. You can also select a service in the Start or Stop section of the dialog, and then click the Edit button to assign a number to the service in order to change the order in which the process is started or stopped when entering or leaving a particular runlevel.
Using tksysv sure beats doing everything by hand. But be careful! Making changes by hand-editing the default runlevel for /etc/inittab or using tksysv to change runlevels can put your system into an unusable state. Here's a handy tip from the help menu in tksysv:
"If you do mess up, you can get in to fix it by rebooting and doing
LILO boot: linux single
This should allow you to boot into single-user mode so you can fix it."
By now you've learned not only how Linux starts, but also a little bit about how it shuts down. If you look at the scripts in runlevel 0, you'll find a number of services being shut down, followed by the killing of all active processes, and finally, the halt script in inet.d executing the shutdown.
The halt script is used to either halt or reboot your system, depending on how it is called. But what happens during a shutdown? If you're familiar with other operating systems such as DOS, you remember that all you had to do was close any active application and then turn off the computer. Although Linux is easy to use, shutting down your computer is not as simple as turning it off. (Although you can try this if you wish, you do so at your own risk!) There are a number of processes that must take place before you or Linux turns off your computer. Let's take a look at some of the commands involved.
Although many people use Linux as a single user on a single computer, many of us use computers either on a distributed or shared network. If you've ever been working under a tight deadline in a networked environment, then you know the dreadful experience of seeing the "System is going down in 5 minutes!" message from the system administrator. You might also know the frustration of working on a system on which the system administrator is trying to perform maintenance, suffering seemingly random downtimes or frozen tasks.
Luckily for most users, these jobs are performed during off hours, when most people are home with their loved ones, or fast asleep in bed. Unluckily for sysadmins, this is the perfect time for
Page 45
system administration or backups, and one of the top reasons for the alt.sysadmin.recovery newsgroup!
The primary command to stop Linux is the shutdown command. Like most UNIX commands, shutdown has a number of options. Curiously, no man page for the shutdown command is included in Red Hat Linux 4.2, but you can find its command-line syntax because it displays a small help message if you use an illegal option. Thanks to the programmer, here it is:
Usage: shutdown [-krhfnc] [-t secs] time [warning message] -k: don't really shutdown, only warn. -r: reboot after shutdown. -h: halt after shutdown. -f: do a `fast' reboot. -n: do not go through "init" but go down real fast. -c: cancel a running shutdown. -t secs: delay between warning and kill signal. ** the "time" argument is mandatory! (try "now") **
To properly shutdown your system immediately, use
# shutdown -h now
If you want to wait for a while, use the -t option. If you want to restart your computer, use
# shutdown -r now
The lack of documentation for shutdown in the Red Hat Linux can be troublesome, but even more curious is the presence of two text strings embedded in the program:
"You don't exist. Go away." "(Well hello Mr. Tyler - going DOWN?)"
which were found by executing:
# strings /sbin/shutdown
Hint: To find out about "You don't exist. Go away.", see Ian Jackson's Linux Frequently Asked Questions with Answers. You should be able to find a copy at ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO.
There are two other commands that will also stop or restart your system: the halt and reboot commands. reboot is a symbolic link to halt. halt notifies the kernel of a shutdown or reboot. Although you should always use shutdown to restart your system, there is another command you can use: the Vulcan neck pinch, ctrlaltdel.
If you use the keyboard form of this command, you'll find that Linux uses the following command:
# shutdown -t3 -r now
If you use the command-line form of this approach, you have two options: hard or soft. Because a hard reset will restart your computer without calling the sync command, a soft reset is
Page 46
preferred. Why? Because sync updates the inodes of your files, or structure representations of each of your files. If you exit Linux without updating this information, Linux could lose track of your files on disk, and that spells disaster!
NOTE |
The only time you'll want to risk shutting down Linux through a hard reset or the power-off switch on your computer is if you can't quickly kill a destructive process, such as an accidental rm -fr /*. |
By now you should know that exiting Linux properly can help you avoid problems with your system. But what happens if something goes wrong? In the next section you'll learn about preventive measures, how to maintain your filesystem, and how to recover and overcome problems.
The best time to deal with a system crash is before the crash happens. This means being prepared with a good backup plan, good backups, emergency boot disks, or copies of important files. These issues are covered in this section, along with tips and hints for maintaining your filesystem integrity and system security.
First, here are some Do's and Don'ts to avoid problems: