天天看點

CentOS 6和CentOS 7管理系統服務的差別

管理系統服務

CentOS 6

CentOS 7

(firewalld.service可簡寫成firewalld

httpd.service可簡寫成httpd)

關閉防火牆

# service iptables stop

# systemctl stop firewalld.service

禁止防火牆開機自啟

# chkconfig iptables off

# systemctl disable firewalld.service

檢視防火牆是否運作

# service iptables status

# firewall-cmd --state

暫時關閉SELinux

# setenforce 0

禁止SELinux開機自啟

(永久關閉SELinux)

# vim /etc/selinux/config  -->   SELINUX=disabled  # reboot

檢視SELinux狀态

# getenforce

啟動httpd服務

# service httpd start

# systemctl start httpd.service

停止httpd服務

# service httpd stop

# systemctl stop httpd.service

重新開機httpd服務

# service httpd restart

# systemctl restart httpd.service

條件式重新開機httpd服務

(服務之前已經啟動-->重新開機

服務之前沒有啟動-->不做任何操作)

# service httpd condrestart

# service httpd try-restart

# systemctl condrestart httpd.service

# systemctl try-restart httpd.service

重載httpd服務

# service httpd reload

# systemctl reload httpd.service

重載或重新開機httpd服務

(服務支援重載-->重載

服務不支援重載-->重新開機)

# systemctl reload-or-restart httpd.service

重載或條件式重新開機httpd服務

服務不支援重載且之前已經啟動-->重新開機

服務不支援重載且之前沒有啟動-->不做任何操作)

# systemctl reload-or-try-restart httpd.service

檢視httpd服務是否運作

# service httpd status

# systemctl is-active httpd.service

# systemctl status httpd.service

設定httpd服務開機自啟

# chkconfig httpd on

# systemctl enable httpd.service

禁止httpd服務開機自啟

# chkconfig httpd off

# systemctl disable httpd.service

檢視httpd服務是否開機自啟

# chkconfig --list httpd

# systemctl is-enabled httpd.service

列出所有正在運作的服務

# systemctl list-units --type service

列出所有服務的開機自啟狀态

# chkconfig --list

# systemctl list-unit-files --type service

禁止設定httpd服務開機自啟

(禁用# systemctl enable httpd.service)

# systemctl mask httpd.service

取消禁止設定httpd服務開機自啟

(恢複# systemctl enable httpd.service)

# systemctl unmask httpd.service

檢視httpd服務的依賴關系

# systemctl list-dependencies httpd.service

結束所有httpd程序

# killall httpd

# systemctl kill httpd

      本文轉自Marion0728  51CTO部落格,原文連結:http://blog.51cto.com/qiuyue/1950471,如需轉載請自行聯系原作者

繼續閱讀