systemctl

System Service Manager Directives

Supplementary instructions

systemctl command is a system service manager command, which actually combines the two commands service and chkconfig.

TasksOld CommandsNew Commands
Make a service start automaticallychkconfig --level 3 httpd onsystemctl enable httpd.service
Prevent a service from starting automaticallychkconfig --level 3 httpd offsystemctl disable httpd.service
Check service statusservice httpd statussystemctl status httpd.service (service details) systemctl is-active httpd.service (only shows whether Active)
Show all started serviceschkconfig --listsystemctl list-units --type=service
Start serviceservice httpd startsystemctl start httpd.service
Stop serviceservice httpd stopsystemctl stop httpd.service
Restart serviceservice httpd restartsystemctl restart httpd.service
Reload serviceservice httpd reloadsystemctl reload httpd.service

Example

systemctl start nfs-server.service . # Start nfs service
systemctl enable nfs-server.service # Set up auto-start at boot
systemctl disable nfs-server.service # Stop auto-start at boot
systemctl status nfs-server.service # View the current status of the service
systemctl restart nfs-server.service # Restart a service
systemctl list-units --type=service # View all started services

Open firewall port 22

iptables -I INPUT -p tcp --dport 22 -j accept

If you still have problems, it may be caused by SELinux

Turn off SElinux:

Modify SELINUX="" in the /etc/selinux/config file to disabled, and then restart.

Turn off the firewall completely:

sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service