Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Linux+ Certification Bible.pdf
Скачиваний:
46
Добавлен:
15.03.2015
Размер:
3.78 Mб
Скачать

494

Part VI Troubleshooting and Maintaining System Hardware

For example, if you need to find the location of your resolv.conf file, simply enter the following command:

locate resolv.conf

The following is the output of the command:

/etc/resolv.conf

If you don’t know the name of the file, you can type a certain amount of characters, and locate it will match all files with that string of characters. Using this functionality, however, may bring up a large number of matches that you will have to search through.

The database of files is updated routinely by a system cron job. You can also update the database manually by using the command updatedb.

Another command that you can utilize for file searching is find. The find command searches the specified directory for the file that you are looking for. This command is helpful if you already know the general directory. For example, you may be looking for a configuration file that you know resides in the /etc directory, but you aren’t sure of the subdirectory. You can use the following command:

find /etc -name “httpd.conf”

This command provides the following output:

/etc/httpd/conf/httpd.conf

Know how to use the various command line tools to help you navigate your log and configuration files more efficiently.

Process Configuration and Management

6.4 Examine, start, and stop processes based on the signs and symptoms of a problem

Often, you will find that a system process ends or becomes unresponsive. Usually, the users notice this situation right away — especially if the process is very important, such as a Web or Samba server. Knowing how to stop, start, and restart these services is a very important troubleshooting skill. Sometimes, you can quickly fix a problem by stopping and restarting a service, or by changing a process configuration file and restarting the service with new values.

The basic command that you can use to identify current running services is the ps command. This command shows all running processes on the system by using the ps -ef command.

Chapter 16 Linux Troubleshooting Basics 495

By using the grep command, you can narrow the list down to the process that you are currently examining. For example, if you want to see whether the httpd Web server daemon is running, you can issue the following command:

ps -ef | grep httpd

If users are complaining that the Web server is not running, you can use this command to see if the process even exists. If it does exist, it may be a stuck process, but if it isn’t present, it may have stopped abnormally.

In either case, examine the applications log file to see if any error messages are present to indicate why the process may have become frozen or stopped. You should also check the general system log file /var/log/messages for any system-wide problems, such as lack of disk space. If you can’t find any immediate reason, the best thing to do is to start or restart the process.

Stopping, Starting, and Restarting Processes

Most services and daemons have their process script stored in /etc/rc.d/ init.d. Each script contains detailed commands to execute, stop, start, or restart the process as required. You can run this script with the particular option that you need to perform. For example, if you want to stop the running httpd process, change directories to /etc/rc.d/init.d/ and issue the following command:

./httpd stop

If the process is frozen, stopping the process with its own script doesn’t always work. In this event, you may need to use the “kill” command to end the process.

This command runs the script with the “stop” parameter and the process should halt. You can check the results by performing the ps -ef command again to see if it is still running.

If you want to start the process again, you can issue the following command:

./httpd start

Use the ps -ef command again to ensure that the process is running properly.

To restart a running process — which you may need to do if the process is frozen — or if you need to read new values from the application’s configuration file, use the following command:

./httpd restart

Соседние файлы в предмете Операционные системы