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

  1. Basic syntax:Systemctl [start | stop | restart | status] service name
  2. systemctlCommand managed services in /usr/lib/systemd/systemTo view

2. Systemctl Sets the automatic startup status of the service

  1. Systemctl list - unit - files [| grep service name](Check service startup status,grepCan be filtered)

  2. Systemctl enable Specifies the service name(Set service startup), yes3(No interface) and5(GUI) runlevels are in effect
  3. Systemctl disable Service name(Turn off the service and start up), yes3(No interface) and5(GUI) runlevels are in effect
  4. Systemctl 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:

  1. 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

  1. 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.
  2. This parameter is used if you want to set a service to take effect permanentlySystemctl [enable | disable] service name
  • Use firstSystemctl is-enabled Specifies the service nameThe (To query whether a service is self-started) command checks whether the service is self-started

  • usesystemctl stop firewalldThe firewall is still in the self-start state.

  • usesystemctl disable firewalldWhen the system restarts next time, the firewall is still disabled

  • Restart the self-starting firewall: