systemctl
系統(tǒng)服務(wù)管理器指令
補(bǔ)充說明
systemctl命令 是系統(tǒng)服務(wù)管理器指令,它實際上將 service 和 chkconfig 這兩個命令組合到一起。
任務(wù) | 舊指令 | 新指令 |
---|
使某服務(wù)自動啟動 | chkconfig --level 3 httpd on | systemctl enable httpd.service |
使某服務(wù)不自動啟動 | chkconfig --level 3 httpd off | systemctl disable httpd.service |
檢查服務(wù)狀態(tài) | service httpd status | systemctl status httpd.service (服務(wù)詳細(xì)信息) systemctl is-active httpd.service (僅顯示是否 Active) |
顯示所有已啟動的服務(wù) | chkconfig --list | systemctl list-units --type=service |
啟動服務(wù) | service httpd start | systemctl start httpd.service |
停止服務(wù) | service httpd stop | systemctl stop httpd.service |
重啟服務(wù) | service httpd restart | systemctl restart httpd.service |
重載服務(wù) | service httpd reload | systemctl reload httpd.service |
實例
systemctl start nfs-server.service .
systemctl enable nfs-server.service
systemctl disable nfs-server.service
systemctl status nfs-server.service
systemctl restart nfs-server.service
systemctl list-units --type=service
開啟防火墻22端口
iptables -I INPUT -p tcp --dport 22 -j accept
如果仍然有問題,就可能是SELinux導(dǎo)致的
關(guān)閉SElinux:
修改/etc/selinux/config文件中的SELINUX=""為disabled,然后重啟。
徹底關(guān)閉防火墻:
sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service