systemctl 是一个用于管理 Systemd 系统和服务的命令行工具,以下是一些常见的 systemctl 命令以及它们的简要介绍
以下是一些常见的 systemctl 命令以及它们的简要介绍:
systemctl start [unit]
启动指定的服务单元。
systemctl stop [unit]
停止指定的服务单元。
systemctl restart [unit]
重启指定的服务单元,如果服务正在运行,它会先停止再启动。
systemctl reload [unit]
重新加载配置,不需要停止服务。通常用于重新加载配置文件,如重新加载 Nginx 或 Apache 配置。
systemctl enable [unit]
在系统启动时自动启用指定的服务单元,使其成为启动时启动的服务。
systemctl disable [unit]
在系统启动时自动禁用指定的服务单元,使其不会在启动时启动。
systemctl status [unit]
显示指定服务单元的状态信息,包括是否正在运行以及最后一次的日志条目。
systemctl is-active [unit]
检查指定的服务单元是否正在运行,如果正在运行返回 "active",否则返回 "inactive"。
systemctl is-enabled [unit]
检查指定的服务单元是否在系统启动时启用,如果已启用返回 "enabled",否则返回 "disabled"。
systemctl list-units
列出当前在系统上运行的所有单元(包括服务单元、套接字单元等)。
systemctl list-unit-files
列出所有可用的单元文件,包括已启用和已禁用的。
systemctl daemon-reload
重新加载 Systemd 系统管理守护进程的配置文件。当手动编辑单元文件后,需要运行此命令以使更改生效。