After looking at the lengthy process lists in the preceding sections, you might be wondering just what most of the listed processes actually are. Even though Fedora Core 4 is intended to be a desktop-oriented operating system, many of these pro cesses are system and network services of the sort that servers typically offer. In the Unix world, even desktops often need to perform server-oriented tasks such as accepting remote logins or transferring files across the network. As Linux operates, some of the services it offers are running and others aren't. The default set of services running at any given time is determined by the system's current runlevel. A Linux system is always at a specific runlevel; available runlevels are numbered 0 through 6. Each runlevel is associated with a specific list of services, which are started when the system enters the runlevel. Changes to the list of running services can be made by manipulating the list of services associated with the current runlevel or by changing the default runlevel at which the system operates; both of these tasks are discussed in the following sections. Understanding RunlevelsWhen your Linux system boots, the first process started by the kernel (the core of the operating system) is called init. The init process is responsible for starting all other processes in the systemfrom the system and network services to the graphical desktop environment. So, how does the init command know what to start? One primary file, the /etc/inittab file, controls just what init does each time the system starts. A complete description of the format of the /etc/inittab file is beyond the scope of this book, and is better left to an advanced text on system administration. Near the beginning of the /etc/inittab file, however, you see a line that begins with the letters id, something like this one: id:5:initdefault: This line decides the default runlevel of your Fedora Core 4 system. The system in this example has a default runlevel of 5. Recall that seven runlevels are available, numbered 0 tHRough 6. A list of these runlevels and their traditional meanings is shown in Table 28.2.
At any given time, a Linux system is running at a runlevel between 0 and 6. Controlling the list of automatically started services on your Linux system is a matter of setting a default runlevel and then configuring the services associated with that runlevel. You can change the default runlevel at which your system starts by editing the id line in the /etc/inittab file and inserting the runlevel number of your choice. For example, if you want to start with a default runlevel of 3, you edit the line to read as follows: id:3:initdefault: You learn how to control the list of services associated with each runlevel by using the chkconfig command in the next section.
Selecting Automatically Started ServicesIn Fedora Core 4, the /sbin/chkconfig command is used at the command line to manage the list of services that are started automatically each time the system starts at a given runlevel. To see a list of available services and the current status of each with respect to each runlevel, call the chkconfig command using the --list option. The output appears in two parts, as shown in the following output fragments: [root@workstation20 you]# /sbin/chkconfig --list NetworkManager 0:off 1:off 2:off 3:off 4:off 5:off 6:off acpid 0:off 1:off 2:off 3:on 4:on 5:on 6:off anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off [...] vncserver 0:off 1:off 2:off 3:off 4:off 5:off 6:off winbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off ypbind 0:off 1:off 2:off 3:off 4:off 5:off 6:off yum 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@workstation20 you]#
There are two components to the output of the chkconfig command:
A complete listing of, and set of descriptions for, all these services is beyond the scope of this book and better left to a book on Unix-style networking. However, some of the best-known services that can appear in the output of chkconfig are described in Table 28.3.
You can globally enable or disable any of the services in Table 28.3 or the services in the chkconfig --list output by calling chkconfig and supplying first the name of the service and then the word on or off as an argument. For example, to completely disable both web service and incoming telnet service, you would enter the following two commands: [root@workstation20 you]# /sbin/chkconfig httpd off [root@workstation20 you]# /sbin/chkconfig telnet off [root@workstation20 you]# You can easily check to see whether your changes have taken effect by using the chkconfig --list command again in combination with the grep command to filter the output. For example, to check on the new status of the httpd service, enter the following: [root@workstation20 you]# /sbin/chkconfig --list | grep httpd httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@workstation20 you]# For services not managed by xinetd (those in the first half of the chkconfig listing), you can also enable or disable services on a runlevel-by-runlevel basis by using the --level option, supplying the level to change as the first argument. For example, to reenable web service for runlevel 3 only and verify the result, you enter the following commands: [root@workstation20 you]# /sbin/chkconfig --level 3 httpd on [root@workstation20 you]# /sbin/chkconfig --list | grep httpd httpd 0:off 1:off 2:off 3:on 4:off 5:off 6:off [root@workstation20 you]#
After making changes to your chkconfig configuration, you need to reboot or use the service command in the next section for the changes you've made to your current runlevel to take effect. Stopping, Starting, and Restarting Running ServicesSometimes over the course of a network's lifetime, it is helpful to be able to temporarily stop a running service that is normally offered, to temporarily offer a service that is not normally offered, or to restart a running service on your Linux system. Often this is the case when you have changed a configuration file or when a service seems to have become unstable or overloaded. You do not need to use the chkconfig utility or restart your system to make temporary changes of this sort. You can use the service command to stop, start, or restart running services one by one. To do this, call the service command, supplying the service whose name matches an entry in the chkconfig service list as the first argument and either stop, start, or restart as a second argument. For example, to start the httpd service when it hasn't already been running, enter the following command: [root@workstation20 you]# /sbin/service httpd start Starting httpd: [ OK ] [root@workstation20 you]# To stop the service once again, call service with httpd as an argument again, but with stop as the second argument instead: [root@workstation20 you]# /sbin/service httpd stop Stopping httpd: [ OK ] [root@workstation20 you]# The restart argument is used in the same way to force a running service to restart, usually after you edit its configuration file (to activate new changes) or if the service has encountered a bug and stopped responding or encountered other problems. The changes you make to the running status of a service this way last only until the system is rebooted; for example, if you call service with httpd start to start your web server but don't have the httpd service enabled via chkconfig, the next time you reboot, the httpd service is not activated automatically. |