---------- 2018-03-16 ServiceSystemCtl.txt.txt 以前只要 service httpd start /etc/init.d/httpd start chkconfig --list chkconfig httpd on 就可操作服務的生死 服務不再是由 init 負責,而是 systemd,而傳統的 runlevel 也改為 target 雖然說以上部份在 CentOS7 還是可以使用啦,只是要漸漸習慣使用 systemctl 才行 systemctl 已不把啟動檔放在 /etc/rc.d/init.d/ 裡面 改放在 /etc/systemd/system 裡,這裡也只放已被 enable ,它是從 /usr/lib/systemd/system/ 這裡 link 過來的 所以使用上一定有不習慣 啟動 systemctl start httpd systemctl start mysql systemctl start mariadb 停止 systemctl stop httpd systemctl stop mysql systemctl stop mariadb 開機後自動啟動 systemctl enable httpd 開機後自動停用 systemctl disable httpd 服務狀態 systemctl status httpd service vsftpd status --> redirection to /bin/systemctl status vsftpd.service 列出全部服務 systemctl list-unit-files 列出服務,正在跑的 systemctl list-units --type service | grep running 顯示目前系統預設運作層級 systemctl get-default 如果顯示 multi-user.target,就以前的 runlevel 3 而 graphical.target 為 runlevel 5 切換運作層級至文字模式 runlevel 3 systemctl isolate multi-user.target 設定開機啟動至文字模式 runlevel 3 systemctl set-default multi-user.target 重啟service service vsftpd restart systemctl restart httpd.service systemctl restart firewalld systemctl restart mysqld.service 其它 systemctl restart httpd.service systemctl reload httpd.service systemctl kill httpd.service systemctl show httpd.service ---------- 啟動服務 sudo systemctl restart vsftpd 開機時自動啟動服務 sudo systemctl enable vsftpd