The article directories
- 1. Systemctl management commands
- 2. Systemctl Sets the automatic startup status of the service
- 3. Application Cases:
- 4. Detailed discussion:
1. Systemctl management commands
- Basic syntax:
Systemctl [start | stop | restart | status] service name
systemctl
Command managed services in /usr/lib/systemd/system
To view
2. Systemctl Sets the automatic startup status of the service
Systemctl list - unit - files [| grep service name]
(Check service startup status,grep
Can be filtered)
Systemctl enable Specifies the service name
(Set service startup), yes3
(No interface) and5
(GUI) runlevels are in effectSystemctl disable Service name
(Turn off the service and start up), yes3
(No interface) and5
(GUI) runlevels are in effectSystemctl is-enabled Specifies the service name
(Check whether a service is automatically started.)
3. Application Cases:
- View the firewall status, disable the firewall, and restart the firewall. = >
firewalld.service
(Service Name)
canWrite halfSee also the full service name, which can also be abbreviated:firewalld.service = firewall
- The firewall starts automatically when the Linux operating system is started.
- View the status of the firewall, now running:
systemctl status firewalld
Copy the code
- Disable the firewall:
systemctl stop firewalld
Copy the code
- Enable firewall:
systemctl start firewalld
Copy the code
4. Detailed discussion:
- The firewall takes effect immediately after it is disabled or enabled. Telnet test a port.
- Example Check the status of port 111
- If the access fails, the firewall does not permit the port
- When the firewall is turned off, you can connect to port 111, other ports are open state
- In this way (
systemctl start/stop firewalld
) Enabling or disabling a service takes effect temporarily. After the system is restarted, the service Settings are restored. - This parameter is used if you want to set a service to take effect permanently
Systemctl [enable | disable] service name
- Use first
Systemctl is-enabled Specifies the service name
The (To query whether a service is self-started) command checks whether the service is self-started
- use
systemctl stop firewalld
The firewall is still in the self-start state.
- use
systemctl disable firewalld
When the system restarts next time, the firewall is still disabled
- Restart the self-starting firewall: