linux-systemctl-使用

在centos7后,系统服务的相关命令改为了systemctl,这里记录一下常用的使用方法

  1. 启动/关闭/重启 服务

    1
    systemctl start/stop/restart ntpd.service
  2. 查看服务状态

    1
    systemctl status ntpd.service
  3. 设置开机自启动

    1
    systemctl enable ntpd.service
  4. 禁止开机启动

    1
    systemctl disable ntpd.service
  5. 查看服务是否开机启动

    1
    systemctl is-enabled ntpd.service
  6. 查看启动失败的服务列表

    1
    systemctl --failed
  7. 搜索服务

    1
    systemctl list-unit-files |grep ntpd