温馨提示×

怎么用Systemd管理Linux服务和进程

小亿
88
2024-04-28 13:22:42
栏目: 智能运维

Systemd 是 Linux 操作系统中一种常用的服务管理器,可以用来管理系统的服务和进程。下面是一些常用的 Systemd 命令来管理 Linux 服务和进程:

  1. 启动一个服务:
sudo systemctl start servicename
  1. 停止一个服务:
sudo systemctl stop servicename
  1. 重启一个服务:
sudo systemctl restart servicename
  1. 查看一个服务的状态:
sudo systemctl status servicename
  1. 启用一个服务,使其在系统启动时自动启动:
sudo systemctl enable servicename
  1. 禁用一个服务,使其在系统启动时不自动启动:
sudo systemctl disable servicename
  1. 查看所有正在运行的服务:
sudo systemctl list-units --type=service
  1. 查看所有已启用的服务:
sudo systemctl list-unit-files --type=service

通过上述命令,您可以轻松地管理 Linux 系统中的服务和进程,确保系统的稳定运行。

0