16.1 Introduction
The essence of a service is a process, but it runs in the background. It usually listens to a certain port and waits for requests from other programs, such as (mysql, sshd, firewall, etc.), so we also call it a daemon process, which is very important in Linux. Important knowledge points.
16.2 Service management instructions:
service service name start|stop|restart|reload|status
Service is no longer used after Centos7.0, but systemctl
16.3 Use Cases
(1) Check the current firewall status, close the firewall and restart the firewall.
(2) After the firewall is turned off or turned on, it will take effect immediately. You can test a port with telnet.
Win10 system defaults to close the Telnet client, we only need to enable this Windows function.
(3) This method only takes effect temporarily. When the system is restarted, it will return to the previous settings for the service.
If you want to set a service to start or shut down permanently, use the chkconfig command
16.4 View service name
Method 1: Use setup, and then select the system service, you can see it.
Method 2: /etc/init.d/service name
16.5 Service Runlevels
Linux systems have 7 runlevels: 3 and 5 are commonly used.
Start-up process description:
16.6 The chkconfig command
Introduction: Through the chkconfig command, you can set auto-start and shutdown for each run level of each service
(1) View service
(2) chkconfig --level 5 service name on/off
Shut down the sshd service with runlevel 5 and start it again
Usage details: chkconfig restarts or shuts down after resetting the service, and needs to restart the machine to take effect.