systemd 的常用命令有哪些?
美国、香港服务器
systemd 的常用命令有哪些?
04-28 来源:
(一)服务管理命令
启动服务:使用systemctl start .service命令可以启动指定的服务。例如,要启动 Apache Web 服务器服务,可以执行systemctl start httpd.service。
停止服务:systemctl stop .service用于停止正在运行的服务。如systemctl stop httpd.service将停止 Apache Web 服务器服务。
重启服务:systemctl restart .service命令可用于重启服务,常用于在服务配置更改后使其生效。例如,修改了 Web 服务器的配置文件后,执行systemctl restart httpd.service可使新配置生效。
查看服务状态:systemctl status .service命令能够查看指定服务的当前状态,包括是否正在运行、启动时间、运行日志等信息。这对于排查服务故障非常有用,例如执行systemctl status httpd.service可以查看 Apache Web 服务器服务的详细运行状态。
(二)单元管理命令
查看所有单元:systemctl list-units命令用于列出当前系统中所有已加载的单元,包括服务单元、设备单元、挂载单元等。通过该命令可以全面了解系统当前的运行状态。
查看特定类型单元:systemctl list-units --type=命令可以筛选出特定类型的单元。例如,systemctl list-units --type=service将只列出所有的服务单元。
启用 / 禁用服务开机自启:systemctl enable .service命令用于设置指定服务在系统开机时自动启动;而systemctl disable .service则用于取消服务的开机自启设置。例如,要让 Apache Web 服务器服务在开机时自动启动,可以执行systemctl enable httpd.service。
三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快