1. 使用 systemctl 管理服务
systemctl 是系统服务管理器命令,它是 service 和 chkconfig 这两个命令的整合,在 CentOS 7 就开始被使用。
1. 启动服务;
systemctl start httpd2. 关闭服务;
systemctl stop hettpd3. 重启服务;
systemctl restart httpd4. 查看一个服务的状态;
systemctl status httpd5. 查看一个服务是否在运行;
systemctl is-active httpd6. 查看当前已经运行的服务;
systemctl list-units -t service7. 列出所有服务;
systemctl list-units -at service8. 设置开机自启动;
systemctl enable httpd9. 停止开机自启动;
systemctl disable httpd10. 列出所有开机自启动服务;
systemctl list-unit-files | grep enabled11. 列出所有开机非自启动的服务;
systemctl list-unit-files | grep disabled12. 将指定服务重新加载;
systemctl reload httpd2. Firewalld 防火墙的设置
1. 临时启动防火墙;
systemctl start firewalld2. 临时关闭防火墙;
systemctl stop firewalld3. 查看防火墙状态;
systemctl status firewalld4. 开机禁用防火墙;
systemctl disable firewalld5. 开机启用防火墙;
systemctl enable firewalld6. 显示防火墙的状态;
firewall-cmd --state7. 查看所有打开的端口;
firewall-cmd --zone=public --list-ports8. 查询80端口;
firewall-cmd --zone= public --query-port=80/tcp9. 开启80端口;
firewall-cmd --zone=public --add-port=80/tcp --permanent10. 关闭80端口;
firewall-cmd --zone= public --remove-port=80/tcp --permanen11. 重新载入(修改防火墙配置后必须重新载入);
firewall-cmd --reload3. SELinux 防火墙的设置
安全增强型 Linux(Security-Enhanced Linux)简称 SELinux,它是一个 Linux 内核模块,也是 Linux 的一个安全子系统。 SELinux 主要由美国国家安全局开发,2.6 及以上版本的 Linux 内核都已经集成了 SELinux 模块。
SELinux 的结构及配置非常复杂,而且有大量概念性的东西,学习难度较大。很多 Linux 系统管理员嫌麻烦都把 SELinux 关闭了,阿里云安装的 centos 默认已经关闭了,西部数码云服务器默认也是关闭的。
1. 查看ESLinux信息;
/usr/sbin/sestatus -v2. 查看ESLinux是否开启;
getenforce3. 关闭ESLinux;
setenforce 0关闭后不用重启服务器。
4. 开启ESLinux;
setenforce 1开启后不用重启服务器。
5. 修改配置文件;
vi /etc/selinux/config在该文件中将将 SELINUX=enforcing 改为 SELINUX=disabled 即可关闭防火墙,修改配置文件后需要重启服务器。









