Linux服務器,服務管理--systemctl命令詳解,設置開機自啓動css
任務 | 舊指令 | 新指令 |
使某服務自動啓動 | 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服務爲例:linux
1.啓動nfs服務bash
systemctl start nfs-server.service
2.設置開機自啓動服務器
systemctl enable nfs-server.service
3.中止開機自啓動tcp
systemctl disable nfs-server.service
4.查看服務當前狀態lua
systemctl status nfs-server.service
5.從新啓動某服務spa
systemctl restart nfs-server.service
6.查看全部已啓動的服務rest
systemctl list -units --type=service
開啓防火牆22端口code
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
若是仍然有問題,就多是SELinux致使的server
關閉SElinux:
修改/etc/selinux/config文件中的SELINUX=」」 爲 disabled,而後重啓
完全關閉防火牆:
sudo systemctl status firewalld.service sudo systemctl stop firewalld.service sudo systemctl disable firewalld.service