systemctl 是 Linux 系统服务管理工具,用于控制系统服务。它可以用于启动/关闭/启用/禁用系统服务。
1.启动服务:
systemctl start <服务名>
2.关闭服务:
systemctl stop <服务名>
3.启用服务:
systemctl enable <服务名>
启用服务后,服务会在系统启动时自动启动
4.禁用服务:
systemctl disable <服务名>
禁用服务后,服务将不会在系统启动时自动启动。
5.查看是否开机自启动
systemctl is-enabled <服务名>
6.查看已启动服务列表
systemctl list-unit-files|grep enabled
7.查看启动失败服务列表
systemctl --failed
除此之外,systemctl 还可以:- 查看服务当前状态:systemctl status <服务名>
- 重启服务:systemctl restart <服务名>
- 查看所有已启动的服务:systemctl list-units --type=service
- 根据 .service 文件的内容启动服务:systemctl start <服务配置文件路径>
systemctl 工具简化了系统服务的管理工作,我们只需要记住几个简单的命令,就可以轻松管理系统中的各种服务。作为 Linux 系统管理员,熟练使用 systemctl 是必备的技能。