chkconfig --list # 列出所有服務等級
chkconfig --add {servicename} # 添加服務
chkconfig {servicename} on # 啟用開機自啟
service {servicename} start|stop|restart|status
| 任務 | 舊指令 (SysV) | 新指令 (systemd) |
|---|---|---|
| 啟用開機自啟 | 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 |