Linux中如何管理服务

lewis 2019-05-29 20次阅读

在Linux系统中,可以使用systemd作为服务管理器来管理服务。以下是一些常用的命令来管理服务:

  1. 启动服务:sudo systemctl start <service_name>
  2. 停止服务:sudo systemctl stop <service_name>
  3. 重启服务:sudo systemctl restart <service_name>
  4. 查看服务状态:sudo systemctl status <service_name>
  5. 开机自启动:sudo systemctl enable <service_name>
  6. 禁止开机自启动:sudo systemctl disable <service_name>
  7. 查看所有已启动的服务:systemctl list-units --type=service
  8. 查看所有已启用的服务:systemctl list-unit-files --type=service
  9. 查看所有服务的状态:systemctl list-units --type=service --all

除了systemd之外,也可以使用其他工具如SysVinit或Upstart来管理服务,但systemd是目前较为常用的服务管理器。



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。