systemctl
是用于与 systemd
初始化系统和服务管理器进行交互的命令行工具。systemd
是许多 Linux 发行版默认的系统和服务管理器,它负责启动和管理系统服务。
以下是一些常用的 systemctl
命令:
启动服务:
sudo systemctl start <service_name>
sudo systemctl start nginx
停止服务:
sudo systemctl stop <service_name>
sudo systemctl stop nginx
重启服务:
sudo systemctl restart <service_name>
sudo systemctl restart nginx
查看服务状态:
sudo systemctl status <service_name>
sudo systemctl status nginx
启用服务开机自启动:
sudo systemctl enable <service_name>
sudo systemctl enable nginx
禁用服务开机自启动:
sudo systemctl disable <service_name>
sudo systemctl disable nginx
查看所有服务状态:
sudo systemctl list-units --type=service
重新加载配置文件:
sudo systemctl daemon-reload
这些命令使系统管理员能够方便地管理和控制系统中的服务。