错误提示
在 Ubuntu 18 系统中执行 chkconfig 命令时,可能会遇到'未找到命令'的错误提示。
解决办法
Ubuntu 自 15.04 版本起已采用 systemd 初始化系统,不再默认支持传统的 service 和 chkconfig 命令。建议使用 systemctl 命令进行服务管理,它整合了原有功能。
常用命令示例
其中 foobar 为服务名称占位符。
- 启动服务:
sudo systemctl start foobar - 停止服务:
sudo systemctl stop foobar - 重启服务:
sudo systemctl restart foobar - 重载配置:
sudo systemctl reload foobar - 设置开机自启:
sudo systemctl enable foobar - 取消开机自启:
sudo systemctl disable foobar - 查看活跃单元:
systemctl list-units - 查看服务状态:
systemctl status foobar - 查看已启动服务列表:
systemctl list-unit-files | grep enabled - 查看启动失败的服务:
systemctl --failed


