Previous Page
Next Page


Like every modern operating system, Linux has quite a bit going on in the background. If you're an average computer useron a Linux, Mac, or Windows systemyou'll rarely have a compelling reason to interact with these background tasks. Most of the time, you won't even realize they're there. The tasks execute on their own and, provided you stay out of their way, they'll stay out of yours. Even as an administrator, you're not likely to need to do much more than start, stop, or restart these services. But don't let the lack of direct contact fool you: these services are critical to the operation of your system.

Linux's system services are generally referred to as daemons . They're applications that run in the background , providing such critical functionality as file and printer sharing, power management, automatic task scheduling, and system logging. For example, your Web server will be running httpd, the HTTP daemon that lies at the heart of Apache. If you make use of MySQL, you'll also need to run the MySQL daemon, mysqld.

The Service Configuration Tool

Figure 4-13. The Service Configuration tool.

The Service Configuration tool , which you can start by selecting Desktop > System Settings > Server Settings > Services, can be used to stop and start services. The tool is shown in Figure 4-13.

To stop or start a service, select it from the list in the left-hand panel. A brief description, along with that service's current status, will be presented on the right. To start a stopped service, click the Start button at the top of the window; to stop a running service, click the Stop button. There is also a Restart button, which can be used to restart a servicean action that can be necessary for certain configuration changes to take effect.

You can also use this tool to configure services to start automatically when the machine is switched on. To do this, check the checkbox next to the service name, and click Save.

Services and Runlevels

Runlevels are basically a convenient way of describing the facilities that are currently available to the system. In runlevel 5, all system functions are available: multiple users can log in, networking features are available, and the GUI is up and running. As the system starts, and system functions become available, other runlevels are triggered:

Runlevel 1

This is known as single user mode . Only one user can be logged in at a time. No network resources are available.

Runlevel 2

Multiple users may be logged in simultaneously, but no network support is available. This is known as multi-user mode .

Runlevel 3

This is the same as runlevel 2, except that network resources have become available. This runlevel is sometimes referred to as full multi-user mode.

Runlevel 5

In addition to everything that's available in runlevel 3, the GUI server is also available at this runlevel.

Note: There is no default runlevel 4this is reserved for definition by system administration gurus.

Figure 4-14. Editing all runlevels.

The Service Configuration tool allows us to set services to start at runlevels 3, 4, or 5. To alter the services that start at a given runlevel, select an option from the Edit Runlevel menu. You can choose to edit a single runlevel at a time, or edit all three at once by selecting Runlevel All, as shown in Figure 4-14.

Check the boxes to specify which daemons you'd like to have start automatically, and when you'd like them to start, then click Save at the top of the window. Note that if you want a daemon to run in runlevels 3, 4, and 5, you need to check all three boxes. If you only check the box for runlevel 3, the service will be stopped when the system reaches runlevel 5.

Using service to Start and Stop Services

To stop , start, or get the status of a service from the command line, you can use Fedora Core's service tool, which is located in the /sbin directory. Remember that, if you added /sbin to the PATH environment variable, you won't need to prefix the command name with /sbin/ to run it.

[kermit@swinetrek ~]$ su
[root@swinetrek kermit]# /sbin/service httpd status
httpd is stopped
[root@swinetrek kermit]# /sbin/service httpd start
Starting httpd:                                           [  OK  ]
[root@swinetrek kermit]# /sbin/service httpd status
httpd (pid 2928 2927 2926 2924 2923 2922 2921 2920 2917) is running…
[root@swinetrek kermit]# /sbin/service httpd stop
Stopping httpd:                                           [  OK  ]
[root@swinetrek kermit]# exit
[kermit@swinetrek ~]$ 

This tool takes two parameters: the name of the daemon (in this example, httpd) and the action to execute. All services will support the actions start, stop, restart, and status.

Using ntsysv to Start Services Automatically

ntsysv is an unusual command line tool in that it offers an interface similar to the text-based install discussed in Chapter 1, as you can see in Figure 4-15.

Figure 4-15. ntsysv running in the terminal.

By default, ntsysv only edits runlevel 5. You can change this by starting ntsysv with the --level option. For example, ntsysv --level 3 will edit runlevel 3.

Automatically Starting Services with chkconfig

The more traditional command line equivalent of ntsysv is chkconfig .

[kermit@swinetrek ~]$ su
[root@swinetrek kermit]# /sbin/chkconfig --level 345 httpd on
[root@swinetrek kermit]# exit
[kermit@swinetrek ~]$ 

This command sets httpd to start at runlevels 3, 4, and 5. You can get a list of the services that start at each level by running chkconfig --list .

Previous Page
Next Page