Linux.com

Home Learn Linux Linux Tutorials Services Overview: What's Really Running on Your Linux Machine

Services Overview: What's Really Running on Your Linux Machine

One of the marvels of a multi-tasking operating system like Linux is the ability to run any number of programs and services in the background. If you've ever watched a boot-up screen, you've probably seen some of the messages go by as all the different services are loaded. Understanding what's happening behind the scenes will really come in handy when you need to figure out why something isn't working. You don't have to be a Linux guru to interpret a log file as long as you know what to look for.

This tutorial will go over the basics of the Linux startup or boot process and try to lay a foundation to help you understand what's going on. We'll take a look at some of the key configuration files and how you might go about making changes or additions to fit your own needs. Examples of different ways to start and stop services will be shown for openSUSE and Ubuntu.

The Boot Sequence

Every Linux system accomplishes essentially the same steps during the boot process. Once the boot loader takes over from the BIOS/Master Boot Record (MBR), it executes commands in a specific order based on something called run level. Run level 0 is essentially nothing running or the computer halted. Run level 1 is the first level where the computer begins executing instructions and is defined as single-user mode. Run level 2 is the first level where multi-user/multi-tasking takes place.

The control of what services get started happens through a number of scripts stored in the /etc/init.d directory. While there is some difference in the naming of these scripts between distributions, the basic functionality is the same. Debian-based systems will execute /etc/init.d/rcS while Redhat-based systems will run /etc/rc.d/rc.sysinit. The local system boot configuration file is named /etc/rc.d/rc.local. This is where you would place any commands to start a service or run a program not part of the normal boot process.

Execution of the rc.d files is controlled by the /etc/inittab file (/etc/event.d/rc-default in Ubuntu). This script attempts to guess what the default run level should be and then starts the appropriate script. Execution order becomes important when you need to guarantee that one specific process is started before another.

Daemons

All system services run as a child process from the init program typically given the process ID of 1 (PID = 1). The name daemon came from the MIT Project MAC team and was taken from Maxwell's "demon," which was an imaginary being that constantly works in the background sorting molecules. Processes with an ending with the letter d, like cupsd, or with the word daemon, are background applications that respond to specific events such as printing a document (cupsd is the Common Unix Printing Services Daemon).

Most daemons are started as a part of the normal boot process. Some require stopping and restarting like the networking services. You typically start/stop a process by executing a script in the /etc/init.d directory as in:

# /etc/init.d/networking stop 
# /etc/init.d/networking restart

You can accomplish the same thing through a graphical interface that will depend on the distribution you're using.

OpenSUSE

There are several ways to manage services from OpenSUSE including the chkconfig command, the rc command or YaST. The chkconfig command offers a number of options for adding, configuring, deleting, starting and stopping any system service. You can also get a list of the current state of all system services by simply typing chkconfig at a root system prompt. Typing the chkconfig edit command brings up the list of services and their current state in a VI editor window.

YaST provides a graphical interface (see Figure 1) to configure system services in either a simple or expert mode. The difference between the two is that the expert mode allows you to set the run levels that a particular service is started or stopped in. There's a README file in the /etc/init.d directory with a good description of SuSE boot concept and the scripts that get executed.

Ubuntu

Managing services from a Debian-based distribution happens either with the service command or through the services applet under the System Administration menu. Executing the service command in a terminal window with the status-all option shows all system services and their current state. It also shows exactly how to start/stop the service or perform a restart or a reload. This is really helpful when you can't remember the exact syntax or specific name of a service.

Ubuntu's services administration tool (see Figure 2) provides a simple graphical interface with a list of the defined services and a checkbox showing whether the service is currently enabled or not. This dialog must be unlocked with the system password to allow any modifications to be made. The only downside to this method is you will not see every possible service that the command line service utility will show.

Bottom Line

Understanding how background processes get started and how to stop/start or restart a process is a useful skill to have for any Linux user. This tutorial has barely scratched the surface of all the background processes. The Linux Documentation Project has a wealth of information about the different services and how to make them behave.

Additional reading on the various subject areas should help to explain more of the details not covered in this article. A previous Linux.com article has a good overview of the different run levels and what happens in each level. It also has a good description of the rc.d scripts. Wikipedia is another source of information to read up on the Linux boot process.

 

 

 

Comments

Subscribe to Comments Feed

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board