啓動nginx服務
systemctl start nginx.service
設置開機自啓動
systemctl enable nginx.service
停止開機自啓動
systemctl disable nginx.service
查看服務當前狀態
systemctl status nginx.service
重新啓動服務
systemctl restart nginx.service
查看所有已啓動的服務
systemctl list-units --type=service
權限不允許錯誤
systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall開機啓動
firewall-cmd --state #查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running)
但是通常情況下載安裝完CentOS7後,默認情況下SElinux是啓用狀態,
如下所示:
- [root@rdo ~]# sestatus
- SELinux status: enabled
- SELinuxfs mount: /sys/fs/selinux
- SELinux root directory: /etc/selinux
- Loaded policy name: targeted
- Current mode: enforcing
- Mode from config file: enforcing
- Policy MLS status: enabled
- Policy deny_unknown status: allowed
- Max kernel policy version: 28
1、如果要臨時關閉,可以執行
- setenforce 0
此時的狀態如下
- [root@rdo ~]# sestatus
- SELinux status: enabled
- SELinuxfs mount: /sys/fs/selinux
- SELinux root directory: /etc/selinux
- Loaded policy name: targeted
- Current mode: permissive
- Mode from config file: enforcing
- Policy MLS status: enabled
- Policy deny_unknown status: allowed
- Max kernel policy version: 28
- [root@rdo ~]# cat /etc/selinux/config
- # This file controls the state of SELinux on the system.
- # SELINUX= can take one of these three values:
- # enforcing - SELinux security policy is enforced.
- # permissive - SELinux prints warnings instead of enforcing.
- # disabled - No SELinux policy is loaded.
- #SELINUX=enforcing
- SELINUX=disabled
- # SELINUXTYPE= can take one of three two values:
- # targeted - Targeted processes are protected,
- # minimum - Modification of targeted policy. Only selected processes are protected.
- # mls - Multi Level Security protection.
- SELINUXTYPE=targeted
修改該配置文件也可以執行下面的命令來完成
- sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
修改完成後,保存重啓,重啓後狀態如下:
- [root@rdo ~]# sestatus
- SELinux status: disabled