服务管理

服务管理

查看服务状态

systemctl status  服务名

关闭服务

systemctl stop 服务名

启动服务

systemctl start 服务名

关闭开机启动

systemctl disable 服务名

开机启动

systemctl enable 服务名

显示所有已启动的服务

systemctl list-units --type=service

查看服务是否正在运行

systemctl is-active 服务名

查看服务是否开机启动

systemctl is-enabled 服务名

关闭防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

SElinux

修改配置文件使SElinux关闭开机启动

# 复制一份源文件
cp  /etc/selinux/config  /etc/selinux/config.bak

# 替换内容 /etc/selinux/config是他配置文件的路径
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g'  /etc/selinux/config
# enforcing是启动状态
# permissive,关闭有警告
# disabled , 彻底关闭

# 配置文件的修改会在服务器重启后生效,相当于你关掉了一个开机自启动的软件,并不影响他当前的运行状态
# 临时修改运行状态,相当于你把一个开机自启动的软件给关掉了
getenforce  # 查看selinux当前的运行状态
setenforce  # 设置运行状态,只能选择enforcing和disabled ,

  

原文地址:https://www.cnblogs.com/wwg945/p/8954615.html