Whenever you install a service on the Red Hat exams, you'll generally want to make sure that they're active when the person grading your exam boots your system. There are three basic tools used to control services: text commands, text-based tools, and the Red Hat GUI Service Configuration tool.
It's generally fastest to control services at the command line. The chkconfig command gives you a simple way to maintain different runlevels within the /etc/rc.d directory structure. With chkconfig, you can add, remove, and change services; list startup information; and check the state of a particular service. For example, you can check the runlevels where the sendmail service is set to start with the following command:
# chkconfig --list sendmail sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
This indicates that sendmail is configured to start in runlevels 2, 3, 4, and 5. If you want to turn the sendmail service off for runlevel 4, execute the following command:
# chkconfig --level 4 sendmail off
Now sendmail is configured to run only on runlevels 2, 3, and 5. To turn it back on for runlevel 4, run the same command, substituting on for off. With chkconfig, you can also add or delete services with the --add and --del switches. Installing a service sets up the appropriate links within the /etc/rc.d directory hierarchy. Uninstalling that service removes the associated links from the same hierarchy.
The commands need not even be that complex. If you leave out the runlevel, the following commands automatically deactivate the sendmail service in all runlevels and then activate it in runlevels 2, 3, 4, and 5.
# chkconfig sendmail off # chkconfig sendmail on
If you're managing a substantial number of services, the command line can be less efficient. You don't need a GUI, just the ntsysv tool, which you can open with the command of the same name. However, it's a bit tricky; it affects only services in the current runlevel unless you add an appropriate switch.
For example, if you want to activate several services in runlevels 3 and 5, start ntsysv with the following command (don't forget the double-dash):
# ntsysv --level 35
For this section, I've started ntsysv with the noted command and activated the sendmail service (and deactivated spamassassin), as shown in Figure 3-6.
Figure 3-6: Controlling services with ntsysv
Once I complete my changes, I can then check the result with the following command:
# chkconfig --list sendmail sendmail 0:off 1:off 2:off 3:on 4:off 5:on 6:off
The Service Configuration tool shown in Figure 3-7 allows you to select the services that are to be activated in runlevel 3 (text login) and runlevel 5 (GUI login), one level at a time. You can start it in one of two ways in the GUI: run the system-config-services command or choose System | Administration | Server Settings | Services.
Figure 3-7: The Service Configuration tool
When you configure or repair a service, use chkconfig (or a related utility such as ntsysv or system-config-services) to make sure that the service is activated at the appropriate runlevels. Otherwise, you may not get full credit for your work.