Книга: Fedora™ Unleashed, 2008 edition

Starting and Stopping Services Manually

Starting and Stopping Services Manually

If you change a configuration file for a system service, it is usually necessary to stop and restart the service to make it read the new configuration. If you are reconfiguring the X server, it is often convenient to change from runlevel 5 to runlevel 3 to make testing easier and then switch back to runlevel 5 to re-enable the graphical login. If a service is improperly configured, it is easier to stop and restart it until you have it configured correctly than it is to reboot the entire machine.

There are several ways to manually start or stop services or to change runlevels while using Fedora. The traditional way to manage a service (as root) is to call the service's /etc/rc.d/init.d name on the command line with an appropriate keyword, such as start, status, or stop. For example, to start the automated nightly update of the yum RPM package database, call the /etc/rc.d/init.d/yum script like this:

# /etc/rc.d/init.d/yum start
Enabling nightly yum update: [ OK ]

The script executes the proper programs and reports their status. Stopping services is equally easy, and in fact, you can also check the status of some services by using the status keyword like this:

# /etc/rc.d/init.d/yum status
Nightly yum update is enabled.

In this example, the yum script reports that the daemon is running. This information might be useful for other system management tasks.

A much easier way to manually start or stop a service is to use a script named service. Using service, you do not have to know the full pathname to the system service; you need know only the name of the system service you want to manipulate. Using this approach, the previous yum example looks like this:

# service yum start
Nightly yum update is enabled: [ OK ]

Of course, the GUI tools mentioned earlier also have the functionality to start and stop specific services in your current runlevel. The tool you choose is a matter of personal preference; a good system administrator is aware of them all.

Relevant Fedora Commands

Here are some of the commands you learned so far:

chkconfig — Fedora's text-only command-line runlevel configuration utility

ntsysv — Fedora's text-based system services configuration tool for the command line

setup — Actually a bash script, it is a menu to all the individual ncurses-based configuration tools, including ntsysv

system-config-services — Fedora's GUI runlevel configuration tool, named Configure Services

telinit — Changes the current runlevel

Оглавление книги


Генерация: 1.679. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз