linux系统防火墙systemctl,linux systemctl命令详解

systemctl命令是Linux下的一个命令,那么它具体语法是什么呢?下面由学习啦小编为大家整理了linux systemctl命令的相关知识,希望对大家有帮助!

linux systemctl命令说明

systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

linux systemctl命令格式

systemctl is-enabled iptables.service #查询服务是否开机启动

systemctl enable *.service #开机运行服务

systemctl disable *.service #取消开机运行

systemctl start *.service #启动服务

systemctl stop *.service #停止服务

restart *.service #重启服务

systemctl reload *.service #重新加载服务配置文件

systemctl status *.service #查询服务运行状态

systemctl --failed #显示启动失败的服务

systemctl list-unit-files --type=service #列出所有服务(包括启用的和禁用的)

systemctl mask *.service #屏蔽(让它不能启动) s

ystemctl unmask *.service #显示服务

linux systemctl命令实例

1.启动nfs服务

systemctl start nfs-server.service

2.设置开机自启动

systemctl enable nfs-server.service

3.停止开机自启动

systemctl disable nfs-server.service

4.查看服务当前状态

systemctl status nfs-server.service

5.重新启动某服务

systemctl restart nfs-server.service

6.查看所有已启动的服务

systemctl list -units --type=service

7.开启防火墙22端口

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

如果仍然有问题,就可能是SELinux导致的

关闭SElinux: 修改/etc/selinux/config文件中的SELINUX=””为disabled,然后重启。

彻底关闭防火墙:

sudo systemctl status firewalld.service

sudo systemctl stop firewalld.service

sudo systemctl disable firewalld.service

Guess you like

Origin blog.csdn.net/iss_jin/article/details/121923727