systemd服务单元
以前版本的 Oracle Linux 使用 /etc/rc.d/init.d 目录中的脚本来控制服务。
在 Oracle Linux 7(Redhat Linux 7) 中,这些脚本已被 systemd 服务单元取代。
使用 systemctl 命令列出有关服务单元的信息。
列出所有加载的服务单元:
# systemctl list-units --type service --all
要查看启用了哪些服务单元:
# systemctl list-unit-files --type service
www. On IT Road .com
启动和停止服务
service 实用程序 | systemctl 实用程序 | 描述 |
---|---|---|
service name start | systemctl start name | 启动服务 |
service name stop | systemctl stop name | 停止服务 |
service name restart | systemctl restart name | 重新启动服务 |
service name condrestart | systemctl try-restart name | 仅当服务正在运行时才重新启动服务 |
service name reload | systemctl reload name | 重新加载配置 |
service name status | systemctl status name | 检查服务是否正在运行 |
service -status- all | systemctl list-units -type service -all | 显示所有服务的状态 |
显示服务状态
systemd 服务单元对应系统服务。
要显示有关 httpd 服务的详细信息:
# systemctl status httpd
要检查服务是否正在运行(活动)或者未运行(非活动):
# systemctl is-active sshd active
要检查服务是否已启用:
# systemctl is-enabled sshd enabled
启用和禁用服务
chkconfig 实用程序 | systemctl 实用程序 | 描述 |
---|---|---|
chkconfig name on | systemctl enable name | 启用服务 |
chkconfig name off | systemctl disable name | 禁用服务 |
chkconfig -list name | systemctl status name, systemctl is-enabled name | 检查服务是否已启用 |
chkconfig -list | systemctl list-unit-files -type service | 列出所有服务并检查它们是否已启用 |
日期:2020-09-17 00:14:48 来源:oir作者:oir