A Linux service is an application (or set of applications) that runs in the background waiting to be used, or carrying out essential tasks.
Let's start by looking at how the system is set up, and in particular at the directory /etc/rc.d. Here you will find either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab. The system uses these files (and/or directories) to control the services to be started.
The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel. In this example, runlevel 4 is the default and the scripts that define runlevel 4 can be found in /etc/rc.d/rc.4.
And what is a runlevel? You might assume that this refers to different levels that the system goes through during a boot up. Instead, think of the runlevel as the point at which the system is entered. Runlevel 1 is the most basic configuration (simple single user access using an text interface), while runlevel 5 is the most advanced (multi-user, networking, and a GUI front end). Runlevels 0 and 6 are used for halting and rebooting the system.
There are, however, differences between Linux distributions. For instance, Fedora uses runlevel 5 for X-based logins, whereas Slackware uses runlevel 4 to do the same job. Therefore, you should check your documentation before making any changes. This table shows a generic list of configurations (and some examples of different distros) taken from Linux - The Complete Reference (R.Peterson, Osbourne/McGraw-Hill).
Run Level Generic Fedora Core
init 0 Halt Halt
init 1 Single-user mode Single-user mode
init 2 Basic multi-user mode (without networking) User definable (Unused)
init 3 Full (text based) multi-user mode Multi-user mode
init 4 Not used Not used
init 5 Full (GUI based) multi-user mode Full multi-user mode (with an X-based login screen)
init 6 Reboot Reboot
Features:
1. Start|Stop|Adjust runlevels of services
2. Three tools are available
a. 'chkconfig' - Shell
b. 'ntsysv' - TUI
c. 'system-config-services' - GUI
Tasks:
1. 'chkconfig' - manages both: 'SYSV' & 'XINETD'
a. 'cknconfig' - enumerates all services
b. '--list vsftpd' - enumerates runlevel information for service 'vsftpd'
Note: '/etc/init.d' - services repository
c. '--level 2345 vsftpd off'
d. 'chkconfig vsftpd on | off' - synonym for run-levels 2-5
e. 'chkconfig tftp on' enables XINETD-controlled service: 'tftp'
f. 'chkconfig vsftpd --list' -- to list in which Runlevel service is on.
g. 'chkconfig --level 123456 vsftpd on' - on the service in all runlevels.
Note: XINETD-controlled services are automatically enabled | disabled by 'chkconfig'
Note: However, SYSV-controlled services are NOT automatically started | stopped
Note: Use 'service service_name start|stop' to control service
2. 'ntsysv' - defaults to managing services in the current run-level
Manages both 'SYSV' and 'XINETD' services
a. 'ntsysv --level 35' - influences ONLY the levels specified on the CLI
Note: 'ntsysv' will NOT change the other, unspecified, run-levels
3. 'system-config-services' - GUI - Manages 'SYSV' and 'XINETD' services
Note: XINETD-controlled services are automatically enabled | disabled by 'chkconfig'
Note: However, SYSV-controlled services are NOT automatically started | stopped
Note: Use 'service service_name start|stop' to control service
2. 'ntsysv' - defaults to managing services in the current run-level
Manages both 'SYSV' and 'XINETD' services
a. 'ntsysv --level 35' - influences ONLY the levels specified on the CLI
Note: 'ntsysv' will NOT change the other, unspecified, run-levels
3. 'system-config-services' - GUI - Manages 'SYSV' and 'XINETD' services
No comments:
Post a Comment