center os 7

啓動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 #停止firewall
systemctl disable firewalld.service #禁止firewall開機啓動
firewall-cmd --state #查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running)

但是通常情況下載安裝完CentOS7後,默認情況下SElinux是啓用狀態,

如下所示:

[csharp] view plaincopy
 
  1. [root@rdo ~]# sestatus  
  2. SELinux status:                 enabled  
  3. SELinuxfs mount:                /sys/fs/selinux  
  4. SELinux root directory:         /etc/selinux  
  5. Loaded policy name:             targeted  
  6. Current mode:                   enforcing  
  7. Mode from config file:          enforcing  
  8. Policy MLS status:              enabled  
  9. Policy deny_unknown status:     allowed  
  10. Max kernel policy version:      28  

1、如果要臨時關閉,可以執行

[cpp] view plaincopy
 
  1. setenforce 0  

此時的狀態如下

[html] view plaincopy
 
  1. [root@rdo ~]# sestatus  
  2. SELinux status:                 enabled  
  3. SELinuxfs mount:                /sys/fs/selinux  
  4. SELinux root directory:         /etc/selinux  
  5. Loaded policy name:             targeted  
  6. Current mode:                   permissive  
  7. Mode from config file:          enforcing  
  8. Policy MLS status:              enabled  
  9. Policy deny_unknown status:     allowed  
  10. Max kernel policy version:      28  
2、如果要永久關閉,可以修改配置文件/etc/selinux/config,將SELINU置爲disabled。
[html] view plaincopy
 
  1. [root@rdo ~]# cat /etc/selinux/config   
  2.   
  3. # This file controls the state of SELinux on the system.  
  4. SELINUXcan take one of these three values:  
  5. #     enforcing - SELinux security policy is enforced.  
  6. #     permissive - SELinux prints warnings instead of enforcing.  
  7. #     disabled - No SELinux policy is loaded.  
  8. #SELINUX=enforcing  
  9. SELINUX=disabled  
  10. SELINUXTYPEcan take one of three two values:  
  11. #     targeted - Targeted processes are protected,  
  12. #     minimum - Modification of targeted policy. Only selected processes are protected.   
  13. #     mls - Multi Level Security protection.  
  14. SELINUXTYPE=targeted   

修改該配置文件也可以執行下面的命令來完成
[html] view plaincopy
 
  1. sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config  

修改完成後,保存重啓,重啓後狀態如下:

[html] view plaincopy
 
  1. [root@rdo ~]# sestatus  
  2. SELinux status:                 disabled  


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章