systemctl 是一个用于管理系统服务和守护进程的命令行工具,它是 Systemd 系统和服务管理器的一部分
systemctl list-units --type=service查看服务状态:systemctl status<service_name>例如,要查看 “httpd” 服务的状态,可以运行:
systemctl status httpd启动服务:systemctl start<service_name>例如,要启动 “httpd” 服务,可以运行:
systemctl start httpd停止服务:systemctl stop<service_name>例如,要停止 “httpd” 服务,可以运行:
systemctl stop httpd重启服务:systemctl restart<service_name>例如,要重启 “httpd” 服务,可以运行:
systemctl restart httpd重新加载服务配置:systemctl reload<service_name>例如,要重新加载 “httpd” 服务的配置,可以运行:
systemctl reload httpd启用服务开机自启:systemctl enable<service_name>例如,要启用 “httpd” 服务在开机时自动启动,可以运行:
systemctl enable httpd禁用服务开机自启:systemctl disable<service_name>例如,要禁用 “httpd” 服务在开机时自动启动,可以运行:
systemctl disable httpd检查服务是否启用:systemctl is-enabled<service_name>例如,要检查 “httpd” 服务是否启用,可以运行:
systemctl is-enabled httpd检查服务是否正在运行:systemctl is-active<service_name>例如,要检查 “httpd” 服务是否正在运行,可以运行:
systemctl is-active httpd检查服务是否失败:systemctl is-failed<service_name>例如,要检查 “httpd” 服务是否失败,可以运行:
systemctl is-failed httpd显示服务的依赖关系:systemctl list-dependencies<service_name>例如,要显示 “httpd” 服务的依赖关系,可以运行:
systemctl list-dependencies httpd显示服务的日志:journalctl -u<service_name>例如,要显示 “httpd” 服务的日志,可以运行:
journalctl -u httpd这些是 systemctl 命令的基本使用方法。要了解更多关于 systemctl 的信息,请参阅其手册页(通过运行 man systemctl 命令)。


