服务管理 systemctl
systemctl -t help ---- 显示可用的单元类型
systemctl list-units --type=service ---- 列出所有当前加载的服务单元
systemctl ---- 列出已加载和活动的单元
systemctl list-unit-files --type=service ---- 以安装单元文件状态
systemctl status sshd.service ---- 查看 ssh 的服务状态
systemctl is-active sshd.service ---- 检查 sshd 服务当前是否处于活动(运行中)状态,会返回 active(活动)或 inactive(非活动)等结果。
systemctl is-enable sshd.service ---- 查询 sshd 服务是否设置为开机自启动,返回 enabled(已启用)、disabled(已禁用)等状态。
systemctl is-failed sshd.service ---- 检查 sshd 服务是否启动失败,返回 failed(失败)或 active(正常)等状态。
systemct restart/start/stop sshd ---- 分别用于重启、启动、停止 sshd 服务(sshd.service 可简写为 sshd)。
systemctl --failed --type=service ---- 列出所有失败的单元
服务和进程的关系:
服务是软件运行在系统上的程序
进程是在内存中使用的程序
服务是进程运行的前提