CentOS 7.0 服務管理 – systemctl 命令

CentOS 7.0中已經沒有service命令,而是啓用了systemctl服務器命令

摘要
systemctl 是系統服務管理器命令,它實際上將 service 和 chkconfig 這兩個命令組合到一起。

任務 舊指令 新指令
使某服務自動啓動 chkconfig –level 3 httpd on systemctl enable httpd.service
使某服務不自動啓動 chkconfig –level 3 httpd off systemctl disable httpd.service
檢查服務狀態 service httpd status systemctl status httpd.service (服務詳細信息) systemctl is-active httpd.service (僅顯示是否 Active)
顯示所有已啓動的服務 chkconfig –list systemctl list-units –type=service
啓動某服務 service httpd start systemctl start httpd.service
停止某服務 service httpd stop systemctl stop httpd.service
重啓某服務 service httpd restart systemctl restart httpd.service



下面以nfs服務爲例:

1.啓動nfs服務

systemctl start nfs-server.service IT網,http://www.it.net.cn 

2.設置開機自啓動

systemctl enable nfs-server.service  

3.停止開機自啓動

systemctl disable nfs-server.service  

4.查看服務當前狀態

systemctl status nfs-server.service  

5.重新啓動某服務 Linux學習,http:// linux.it.net.cn

systemctl restart nfs-server.service  

6.查看所有已啓動的服務 Linux學習,http:// linux.it.net.cn

systemctl list -units --type=service  

開啓防火牆22端口 IT網,http://www.it.net.cn

iptables -I INPUT -p tcp --dport 22 -j ACCEPT  

如果仍然有問題,就可能是SELinux導致的

關閉SElinux:

修改/etc/selinux/config文件中的SELINUX=”” 爲 disabled,然後重啓 IT網,http://www.it.net.cn

徹底關閉防火牆:

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