LInux:服务的管理-systemctl

使用systemctl管理服务
服务的启动与停止
服务的启动与停止 
命令格式:systemctl 选项 服务名 
选项说明: 
start:启动;stop:停止;restart:重启;status:服务状态 
服务名:一般以“.service”结尾,输入服务名时了可省略。
设置服务的自启动状态
使用 ntsysv 命令设置服务的自启动 
命令格式:ntsysv [--back][--level] 
ntsysv 图形化设置开机自动启动
空格选中是否启动
TAB键切换按钮
选项说明:back,在互动界面不显示 cancel;level,在指定的运行级别中设置服务的自启动。 

使用 systemctl 命令设置服务的自启动 
查看服务的自启动状态:systemctl is-enabled [服务名称] 
开启服务的自启动:systemctl enable 服务名称 
关闭服务的自启动:systemctl disable 服务名称 
查看所有服务
查看所有的服务 
命令格式:systemctl [选项] [–type=TYPE] [–all] 
选项说明:
list-units:依据 unit 列出所有启动的 unit。加上–all 会列出没启动的 unit;

list-unit-files:依据/usr/lib/systemd/system/ 内的启动文件,列出启动文件列表 –type=TYPE: 为 unit type, 主要有 service, socket, target 
#systemctl //列出所有的系统服务 
#systemctl list-units //列出所有启动 unit 
#systemctl list-unit-files //列出所有启动文件 
#systemctl list-units -type=service -all //列出所有 service 类型的 unit 
#systemctl list-units -type=service -all grep cpu //列出 cpu 电源管理机制的服务
#systemctl list-units -type=target -all //列出所有目标单元 target 
systemctl命令特殊功能
systemctl poweroff 系统关机
systemctl reboot 重新启动
systemctl suspend 进入睡眠模式
systemctl hibernate 进入休眠模式
systemctl rescue 强制进入救援模式
systemctl emergency 强制进入紧急救援模式
原文地址:https://www.cnblogs.com/yanlzy/p/11916899.html