Linux systemctl命令详解

systemctl 是 Linux 系统中用于控制 Systemd 系统和服务管理器的命令行工具。它可以启动、停止、重启、重载或查询系统服务的状态。下面是一些常用的 systemctl 命令:

  • systemctl start :启动服务
  • systemctl stop :停止服务
  • systemctl restart :重启服务
  • systemctl reload :重载服务配置
  • systemctl status :查看服务状态
  • systemctl enable :设置服务开机自启动
  • systemctl disable :关闭服务开机自启动
  • systemctl mask :禁止服务启动
  • systemctl unmask :取消禁止服务启动

使用示例:

启动 Nginx 服务:

systemctl start nginx

查看 Nginx 服务状态:

systemctl status nginx

设置 Nginx 服务开机自启动:

systemctl enable nginx