Linux中用systemctl命令管理服务

systemctl start foo.service 启动服务
systemctl restart foo.service 重启服务
systemctl stop foo.service 停止服务
systemctl reload foo.service 重新加载配置文件(不终止服务)
systemctl status foo.service 查看服务状态

systemctl enable foo.service 开机自启动
systemctl disable foo.service 开机不自启动
systemctl is-enabled foo.service 查看特定服务是否是开机自启动

systemctl list-units 根据unit列出目前所有启动的服务,可通过--type限制类别,加上--all则列出所有服务
systemctl list-unit-files 列出所有服务和其启动与禁用情况,可通过--type限制类别

systemctl mask foo.service 强制注销服务,无法再启动
systemctl unmask foo.service 取消注销服务,恢复正常

注意 服务名foo后的.service可以省略

posted on 2019-12-07 09:53  流年似水zlw  阅读(183)  评论(0编辑  收藏  举报

导航