對於學習過紅帽RHEL6系統或已經習慣使用service、chkconfig等命令來管理系統服務的讀者可能要郁悶一段時間了,因為在紅帽RHEL7系統中管理服務的命令是”systemctl“,但使用方法大致相同,我們來做下對比吧。
systemctl管理服務的啟動、重啟、停止、重載、查看狀態的命令:
| Sysvinit命令(紅帽RHEL6系統) | Systemctl命令(紅帽RHEL7系統) | 作用 |
| service foo start | systemctl start foo.service | 啟動服務 |
| service foo restart | systemctl restart foo.service | 重啟服務 |
| service foo stop | systemctl stop foo.service | 停止服務 |
| service foo reload | systemctl reload foo.service | 重新加載配置文件(不終止服務) |
| service foo status | systemctl status foo.service | 查看服務狀態 |
systemctl設置服務的開機啟動、不啟動、查看各級別下服務啟動狀態的命令:
| Sysvinit命令(紅帽RHEL6系統) | Systemctl命令(紅帽RHEL7系統) | 作用 |
| chkconfig foo on | systemctl enable foo.service | 開機自動啟動 |
| chkconfig foo off | systemctl disable foo.service | 開機不自動啟動 |
| chkconfig foo | systemctl is-enabled foo.service | 查看特定服務是否為開機自啟動 |
| chkconfig --list | systemctl list-unit-files --type=service | 查看各個級別下服務的啟動與禁用情況 |
