Linux system services run on daemon. They are mainly divided into two categories:
1) standalone: You can start services independently, such as httpd and vsftpd. It features fast response, but high resource usage.
2) super daemon: A special unified management of daemon. When the client does not have a request, the services are not started until a request is sent from the client.
Daemon STARTUP script and startup Method
1)/etc/init. d/*: place the Startup Script
2)/etc/sysconfig/*: Service initialization environment configuration file
3)/etc/xinetd. conf and/etc/xinetd. d/*: configuration file of super daemon
4)/etc/*: service configuration file
5)/var/lib/*: database generated by the Service
6)/var/run/*: Service PID
Standalone startup and shutdown Methods
First, put the standalone STARTUP script in the/etc/init. d/directory, and then use the script to start and close the service:
# /etc/init.d/syslogUsage: /etc/init.d/syslog {start|stop|status|restart|condrestart}
You can also use the service command (the effect is the same as that of/etc/init. d ):
service [service name] (start|stop|restart|status|...)service --status-all
How to enable or disable super daemon
Super daemon itself is a standalone service, as shown below:
# /etc/init.d/xinetd statusxinetd (pid 3543) is running...
The service managed by it is super daemon, and their configuration files are stored in/etc/xinetd. d /*
The following is an example:
First, edit the/etc/xinetd. d/rsync file and set disable = no to start the super daemon
Restart the xinetd service:
# /etc/init.d/xinetd restartStopping xinetd: [ OK ]Starting xinetd: [ OK ]
Then, you can see that the service has been started:
# cat /etc/services |grep rsyncrsync 873/tcp # rsyncrsync 873/udp # rsync
Chkconfig-set startup daemon
Chkconfig -- list [service name] -- View chkconfig [-- level [0123456] [service name] [on | off] # view httpd configuration # chkconfig -- list httpdhttpd 0: off 1: off 2: on 3: on 4: on 5: on 6: off # Check which services are automatically started in level 3 # chkconfig -- list | grep '3: on 'crond 0: off 1: off 2: on 3: on 4: on 5: on 6: offhttpd 0: off 1: off 2: on 3: on 4: on 5: on 6: offirqbalance 0: off 1: off 2: on 3: on 4: on 5: on 6: offmicrocode_ctl 0: off 1: off 2: on 3: on 4: on 5: on 6: offmysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: offnetwork 0: off 1: off 2: on 3: on 4: on 5: on 6: offsshd 0: off 1: off 2: on 3: on 4: on 5: on 6: offsyslog 0: off 1: off 2: on 3: on 4: on 5: on 6: offxinetd 0: off 1: off 2: off 3: on 4: on 5: on 6: off # configure httpd to automatically start when the level is 345 # chkconfig -- level 345 httpd on
In addition to setting system services, chkconfig can also add its own services, such:
#vi /etc/init.d/myservice#!/bin/bash# chkconfig: 35 80 70......chkconfig --add myservicechkconfig --del myservice
Netstat-view network services enabled by the System
Netstat-tulp -- find out which network services are currently enabled by the system netstat-lnp -- find all the services with monitoring (including socket status)
References: http://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316661.html