Выбрать главу

If you examine a runlevel directory, you'll see names beginning with K or S , followed by a 2-digit number, followed by a service name:

$ ls /etc/rc.d/rc5.d

K01rgmanager K36postgresql K90isicom

K01yum K45arpwatch K92ipvsadm

K02NetworkManager K46radvd K94diskdump

K02NetworkManagerDispatcher K50netdump S01sysstat

K05innd K50snmpd S04readahead_early

K05saslauthd K50snmptrapd S05kudzu

K09dictd K50tux S06cpuspeed

...(Lines snipped)...

K35vncserver K85mdmpd S97messagebus

K35winbind K85zebra S98cups-config-daemon

K36dhcp6s K87multipathd S98haldaemon

K36lisa K89netplugd S99local

K36mysqld K89rdisc

All of these files are actually symbolic links to service scripts in /etc/rc.d/init.d , as shown by a long listing:

$ cd /etc/rc.d/rc5.d

$ ls -l S90xfs

lrwxrwxrwx 1 root root 13 Oct 5 14:37 S90xfs -> ../init.d/xfs

The scripts that start with S are used to start services, and the scripts that start with K are used to kill (stop) services. K scripts are only used when switching between runlevels after the system has been booted.

The digits in the filename are used to control the sequence in which the scripts are executed. This is essential because some services rely on others; for example, the web server relies on the network being up and running, so the network script must be run first.

When you examine the top of a service script, you will find a comment line containing the keyword chkconfig: followed by three arguments:

$ head /etc/rc.d/rc5.d/S90xfs

#!/bin/bash

#

# Id:$

#

# xfs: Starts the X Font Server

#

# Version: @(#) /etc/init.d/xfs 2.0

#

# chkconfig: 2345 90 10

# description: Starts and stops the X Font Server at boot time and shutdown. \

The first argument ( 2345 ) is a list of the runlevels in which this service will run by default; this information is used to initially set up the system and to handle chkconfig 's reset argument. If the default for this service is to have it turned off in all runlevels, the value - is used. The second argument is the sequence number (00 through 99) for the start link; the value 90 shown here means that the name of the start link will be S90xfs . The third argument is the sequence number for the kill link, which in this case yields a kill-link name of K10xfs .

When service scripts are called, they are passed a keyword such as start , stop , restart , or reload , indicating the action the script must take.

4.6.3. What About...

4.6.3.1. ...creating my own runlevel?

You can use the system-config-services or chkconfig tools to create a custom set of services for a runlevel and then use that either as the default runlevel or an option on the boot menu.

This technique is particularly useful on laptops, which may be used in different locations and need different services in each location.

4.6.3.2. ...creating my own service?

To create a service:

1. Create a service script in /etc/rc.d/init.d . Include a chkconfig line as described in the previous section. (You may want to examine an existing service file to see how it works.)

2. Run the command chkconfig --add service to set up the default service links.

You can then configure your service in the same way as any of the other services, using system-config-services , service , and chkconfig .

4.6.4. Where Can I Learn More?

 The manpages for chkconfig , ntsysv , and init

4.7. Managing Users and Groups

In an age of viruses, worms, and identity theft, keeping information private and secure has taken on great importance. Managing user identity creates the framework for system securityeven on a single-user system, where a distinction is maintained between using the system as the normal user and using the system as the root user.

4.7.1. How Do I Do That?

Almost everyone identifies themselves as both an individual and as a member of several groups. Linux uses separate user and group identities to reconstruct this two-level structure inside the system.

For example, company employee Richard might be all of the following:

 A member of the IT department

 Located at the company's Toronto office

 The leader of the team putting together the big sales pitch to Acme, Ltd.

 Part of the Christmas party committee

 A player in the Tuesday evening company soccer league

(And that doesn't even touch on life outside of the company!)

The system administrator configures Richard's account to indicate his many involvements within the company. At the user level, the name richard is assigned to him, and a password and home directory are assigned. richard is then placed into the groups it , toronto , acmeproposal , christmas , and soccer .

Fedora Core extends this system using a scheme called user private group (UPG), which means that Richard also has his own private group, also named richard . UPG makes a lot of sense when you look at permissions.

4.7.1.1. Managing users graphically

The Fedora GUI tool for managing users and groups is system-config-users , which is accessed through the menu under System→Administration→"Users and Groups." After you supply the root password, the window shown in Figure 4-8 will appear.

Figure 4-8. The Users and Groups configuration window

This window has two tabs, one for managing groups and one for managing users.

To add a user, click on the Add User icon. The window shown in Figure 4-9 will be displayed.

Figure 4-9. The Create New User window