Managing Services in Fedora 1
时间:2007-03-14 来源:hongchenzai
Managing Services in Fedora
Mauriat Miranda (http://www.mjmwired.net/contact/)
Other Guides/Resources
Published: 28 February 2006 (updated: 28 February 2006)
Post To: del.icio.us, furl, digg, spurl, gmail this, Blog this
<STYLE ie7="true">:link { ie7-link: link } :visited { ie7-link: visited } H1 { FONT-SIZE: 2em } H2 { FONT-SIZE: 1.5em } H3 { FONT-SIZE: 1.17em } H4 { FONT-SIZE: 1em } H5 { FONT-SIZE: 0.83em } H6 { FONT-SIZE: 0.67em } { boxSizing: content-box } { minWidth: none; maxWidth: none; min-width: none; max-width: none } { minHeight: none; maxHeight: none; max- FONT-FAMILY: geneva,arial,verdana,lucida,helvetida,sans-serif } A:hover { BACKGROUND-COLOR: #ccc } PRE { BORDER-RIGHT: #000 1px solid; PADDING-RIGHT: 1em; BORDER-TOP: #000 1px solid; DISPLAY: block; PADDING-LEFT: 1em; PADDING-BOTTOM: 1em; BORDER-LEFT: #000 1px solid; PADDING-TOP: 1em; BORDER-BOTTOM: #000 1px solid; BACKGROUND-COLOR: #ddd } TT { BACKGROUND-COLOR: #eee } IMG { BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px } HR { HEIGHT: 7px; ie7- ie7_recalc7: 1 } .guides { BORDER-RIGHT: black 1px dashed; PADDING-RIGHT: 0px; BORDER-TOP: black 1px dashed; PADDING-LEFT: 0px; RIGHT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0.5em 0.5em 0px 0px; BORDER-LEFT: black 1px dashed; PADDING-TOP: 0px; BORDER-BOTTOM: black 1px dashed; LIST-STYLE-TYPE: none; POSITION: absolute; TOP: 1em; BACKGROUND-COLOR: #fff; ie7-position: fixed; ie7_recalc11: 1; ie7-right: 0; ie7_recalc6: 1 } .guides LI { MARGIN: 0px; WIDTH: 8em; ie7-width: 8em; ie7_recalc3: 1 } .guides LI A { PADDING-RIGHT: 0.25em; DISPLAY: block; PADDING-LEFT: 0.25em; FONT-WEIGHT: bold; FONT-SIZE: 11px; PADDING-BOTTOM: 0.25em; PADDING-TOP: 0.25em; FONT-FAMILY: geneva,arial,verdana,lucida,helvetida,sans-serif; BACKGROUND-COLOR: white; TEXT-ALIGN: center } .guides LI A:hover { BACKGROUND-COLOR: #ccc } .corner { BORDER-RIGHT: #000 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #000 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 11px; RIGHT: 0px; PADDING-BOTTOM: 3px; BORDER-LEFT: #000 1px solid; WIDTH: 9em; PADDING-TOP: 3px; BORDER-BOTTOM: #000 1px solid; FONT-FAMILY: geneva,arial,verdana,lucida,helvetida,sans-serif; POSITION: absolute; TOP: 0px; BACKGROUND-COLOR: #f0f0f0; ie7-position: fixed; ie7_recalc11: 1; ie7-right: 0; ie7_recalc6: 1; ie7-width: 9em; ie7_recalc3: 1 } #disclaim { FONT-SIZE: 11px; BACKGROUND-COLOR: #f0f0d0 } #helpout { FONT-SIZE: 11px; BACKGROUND-COLOR: #e0f0f0 } .indent { MARGIN-LEFT: 2em } } </STYLE>
|
Introduction
This guide is to show how to control services in Fedora Core linux. Explanations included are services, runlevels, setting services, and controlling services.
Service
A service (often called a daemon) is a specific application that runs in the background and is usually non-interactive. They can be used for anything, including hardware, network access, monitoring, logging, etc. All operating systems use some set of services to automate actions.
Runlevel
A runlevel is a mode of operation that is used to group certain sets of daemons based on some purpose or restricted use. For the Fedora/Redhat based Linux systems, the primary runlevels in Fedora are:
- runlevel 1: Single-User Mode
- runlevel 2: Multi-User Mode
- runlevel 3: Multi-User Mode with Networking
- runlevel 5: X11 (runlevel 3 + X Window System "the GUI").
Typically most users run with the X-server in runlevel 5, and many servers without X-servers run in runlevel 3. Usually runlevel 1 has no services running.
To determine what runlevel you are using, run:
# /sbin/runlevel
To determing what runlevel your system will start at the next boot, run:
# cat /etc/inittab | grep :initdefault: id:5:initdefault:
Similarily you can edit the file /etc/inittab and change the initdefault value at line ~18.
To switch runlevels, you can run the following, replace RUNLEVEL with the appropriate number (3, 5, etc.):
# /sbin/init RUNLEVEL
Note: When switching FROM runlevel 5 to another runlevel, you might accidentally kill your X-server and entire GUI. Always make sure you are at a text console (CTRL-ALT-F1,F2,F3,F4) before switching runlevels.
To force a runlevel at boot without modifying /etc/inittab, you pass a number to end of the kernel from the Grub menu. At boot, higlight the option you wish to boot and before hitting <Enter>, hit <E>. Go to the end of the kernel line and add a 3 or 5. Then hit <Enter> and boot (<B> to boot).
Enable/Disabling Services
Every service must be set to either be "On" (enabled) or "Off" (disabled) for every runlevel.
To see what services are enabled for each runlevel, run:
# /sbin/chkconfig --list
To control which services are enabled for a runlevel, run system-config-services in the GUI or ntsysv at the command line. (Previous Fedora releases may have serviceconf instead of system-config-services).
To manually enable a specific service use chkconfig. The following command turns crond daemon for both runlevel 3 *AND* 5.
# /sbin/chkconfig --level 35 crond on
The --level could be 1, 2, 3, 4, 5 or any combination of the numbers. The on option can also be off. Running man chkconfig is useful.
Controlling Services
Regardless of how a service is enabled a runlevel or if it is defaulted to "On" or "Off", every service can be started or stopped and managed at runtime.
To see what services you have running run:
# /sbin/service --status-all
To individually control a single service, use service. For example:
# /sbin/service crond status crond (pid 1604) is running...
The status option can be replace with start, stop, status, reload, restart and sometimes other options also. For example:
[root@charon ~]# service crond Usage: /etc/init.d/crond {start|stop|status|reload|restart|condrestart} [root@charon ~]# service crond stop Stopping crond: [ OK ] [root@charon ~]# service crond start Starting crond: [ OK ] [root@charon ~]# service crond restart Stopping crond: [ OK ] Starting crond: [ OK ]
All services located in the directory: /etc/init.d/ can be controlled this way. An alternate form of control would be:
# /etc/init.d/crond status
Virtually all of the above functionality. Is available through the GUI, using system-config-services. However there are times when problems with the GUI (X-server) may prevent you from controlling your services. Hence understanding the commands are very helpful.
reference:
http://www.mjmwired.net/resources/mjm-fedora-manage-services.html