Home  >  Article  >  Operation and Maintenance  >  What are the two categories of services in Linux?

What are the two categories of services in Linux?

青灯夜游
青灯夜游Original
2022-04-12 18:57:242886browse

Linux services are divided into two categories according to management methods: "stand-alone" and "super-daemon", that is, independent management services and unified management services. The independent management service can be started independently without the need for management through other mechanisms; while the unified management service is started and managed through a unified daemon.

What are the two categories of services in Linux?

#The operating environment of this tutorial: CentOS6 system, Dell G3 computer.

Linux system services, also known as daemons, refer to processes that reside in memory and continue to run to provide required services (system or network services).

Classification

Linux system services mainly fall into two categories according to management methods: stand-alone and super-daemon, namely independent management services and unified management services.

stand-alone: ​​This type of service mechanism is relatively simple and can start the service independently. Its characteristics are:

1. It can be started independently without the need for management through other mechanisms
2. Once the stand-alone service is started and loaded into the memory, it will always occupy the memory space and system resource until the service is stopped.
3. Since the service is always running, there is a faster response to client requests.

Typical stand-alone services include: httpd, and ftp

super-daemon: This management mechanism is unified through a The daemon is responsible for starting and managing other services. In CentOS6.X, this super-daemon is the xinetd program. Features are:

1. All services are controlled by xinetd, so there can be a security control mechanism for xinetd, such as network firewall
2. Before clinet request, the required service is not available Started; xinetd will not wake up the corresponding service until the client requests the service; once the connection ends, the corresponding service will be closed. Therefore, the super-daemon method will not always occupy system resources
3. Since the service will be started only when there is a request, the response speed of the server side is naturally not as fast as the stand-alone method

Typical super -Daemon services include: telnet, etc.

Different startup methods

Different services in Linux have different startup scripts to Before starting the service, perform environment detection, configuration file analysis, PID file planning and other related operations. The startup script placement locations in stand-alone mode and super-daemon mode are different, and the startup methods are naturally also different.

stand-alone

Startup script

stand-alone The startup script is located in the /etc/init.d/ directory. In fact, almost all service startup scripts are here.

[root@localhost init.d]# ls /etc/init.d/
abrt-ccpp         htcacheclean    ntpd         smartd
abrtd             httpd           ntpdate      snmpd
xinetd
 ......(省略)

Have you noticed that there are not only stand-alone service startup scripts such as httpd that we know in this directory, but also xinetd! What does this mean?
This shows that the xinetd service actually uses the stand-alone management method. Think about it, because xinetd is responsible for starting and stopping many super-daemon services, does it have to be resident in memory~

Startup method

Method 1: Since all startup scripts are in /etc/init.d/, it would be better to call them directly!

[root@localhost init.d]# /etc/init.d/crond 
Usage: /etc/init.d/crond {start|stop|status|restart|condrestart|try-restart|reload|force-reload}

Calling it directly will tell you the Usage, then

[root@localhost init.d]# /etc/init.d/crond restart
Stopping crond:                                            [  OK  ]
Starting crond:                                            [  OK  ]

it’s that simple!

Method 2: You can also use the service script:

[root@localhost init.d]# service crond status
crond (pid  3278) is running...

This is simpler, but service can only be used to manage stand-alone services.

还有,这个用法可以查看系统所有stand-alone服务的状态

[root@localhost init.d]# service --status-all
abrt-ccpp hook is installed
abrtd (pid  2331) is running...
abrt-dump-oops is stopped
acpid (pid  1807) is running...
......(省略)

NOTE: Since the service script is not available in all Linux distributions, it is recommended to use /etc/init.d/* [action]. It also helps to understand the principle~~~

super-daemon

##Startup script

The super-daemon startup script is placed in /etc/xinetd.d/.

[root@localhost xinetd.d]# ls /etc/xinetd.d/
chargen-dgram   daytime-stream  echo-dgram   tcpmux-server  time-stream
......(省略)
Check what services are started in super-daemon mode:

Method 1: Use chkconfig to see the startup status of services in xinetd based services:

[root@localhost xinetd.d]# chkconfig 
......
xinetd based services:
    echo-dgram:     off
    echo-stream:    off
    rsync:          off
    tcpmux-server:  off
    telnet:         on
    ......
Method 2: Directly view the startup script of the service


[root@localhost xinetd.d]# grep -i 'disable' /etc/xinetd.d/*
......
/etc/xinetd.d/daytime-dgram:    disable     = yes
/etc/xinetd.d/daytime-stream:   disable     = yes
/etc/xinetd.d/discard-dgram:    disable     = yes
/etc/xinetd.d/discard-stream:   disable     = yes
/etc/xinetd.d/echo-dgram:   disable     = yes
/etc/xinetd.d/telnet:   disable = no
......
disable=no above means that the service is enabled.


Startup method

#We already know that if there is a disable=no in the startup script, it means that the service is turned on, so we The startup method is:

1. First edit the startup script and change the disable item of the service that needs to be enabled to no

2. Then restart xinetd: /etc/init.d/xintd restart [because xinetd It is a stand-alone service]

Related recommendations: "

Linux Video Tutorial"

The above is the detailed content of What are the two categories of services in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn