By submitting my Email address I confirm that I have read and accepted the Terms of Use and Declaration of Consent.

By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.

You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.

management. No matter which flavor of Linux you're using, all services are offered by your server as processes.

Finding services

Figure 1. The processes that the Linux administrator has started from the current shell, called up by the
ps command.

The very first task a Linux administrator should be interested in is process management. Start by getting an overview of what your server is doing; the ps command calls up a list of all currently running processes. From a root terminal, make sure a shell is started and you have logged in as root. You can do that either by typing the user name root and the associated password at the login prompt, or by logging in with your normal user account and using the command sudo su to open a root shell.

Figure 2. All processes that are active on a Linux server, as called up by the
ps aux command.

Normally the list of processes that ps discovers will be very short, as it only shows the processes that you've started from the current shell (see Figure 1). Many more processes, by default, are active on your server, and you can get a list with the ps aux command. On a typical server that isn't doing anything special, expect to see 150 processes or more.

Figure 3. The grep utility allows Linux admins to show only lines that contain a specific phrase.

Linux administrators often want to know if a specific process is running. Rather than browsing the list of active processes, you can use Linux pipes -- or program redirects -- and the versatile grep command-line utility. Using piping, you can send the output of one command to the command after the pipe: That will treat the output of the first command as input. You also can use the grep utility in a pipe to search lines that contain a specific string of characters. For example, to find out if your Web server is currently running, you would look for lines containing the text httpd, using the command ps aux | grep httpd. The ps part of the command generates a list of all processes currently running, which the grep utility filters to show only lines containing the text httpd (see Figure 3).

Starting services

If the process you need is not running, you can start it manually. On most Linux servers, the directory /etc/init.d contains a list of scripts that you can use to start services: use cd /etc/init.d to access the directory and type ls to show the list of services on your server (see Figure 4). While this procedure will work for the majority of Linux servers, the latest Linux distributions may use a different procedure.

Figure 4. A list of service scripts that Linux administrators can start manually.

Often the names of the service scripts make sense; for example, the httpd process is started by the httpd service script (see Figure 4). Once you find the name of the service script you need from the list of files in the directory /etc/init.d, you can use the service command to start it. In this example, the command would read service httpd start.

The service command can be used for other purposes as well. You can use it to restart a service, or request current status information. To find out if your httpd service -- or any other Linux process -- is currently running, you can use service httpd status. If it is running and you need to restart it, you can use service httpd restart.

Always type the exit command to close your root shell; you should never walk away from a server that has an open root shell.

Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance. He has authored many books on Linux topics, including Beginning the Linux Command Line, Beginning Ubuntu LTS Server Administration and Pro Ubuntu Server Administration.

1 comment

Register

Login

Forgot your password?

Your password has been sent to:

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy