共计 1315 个字符,预计需要花费 4 分钟才能阅读完成。
Linux 服务治理两种形式 service 和 systemctl,systemd 是 Linux 零碎最新的初始化零碎 (init), 作用是进步零碎的启动速度,尽可能启动较少的过程,尽可能更多过程并发启动。systemd 对应的过程治理命令是 systemctl
chkconfig 和 systemctl 命令比照
工作 | 旧指令 | 新指令 |
---|---|---|
使某服务主动启动 | chkconfig –level 3 httpd on | systemctl enable httpd.service |
使某服务不主动启动 | chkconfig –level 3 httpd off | systemctl disable httpd.service |
查看服务状态 | service httpd status | systemctl status httpd.service(服务详细信息)systemctl is-active httpd.service(仅显示是否 Active) |
显示所有已启动的服务 | chkconfig –list | systemctl list-units –type=service |
启动服务 | service httpd start | systemctl start httpd.service |
进行服务 | service httpd stop | systemctl stop httpd.service |
重启服务 | service httpd restart | systemctl restart httpd.service |
重载服务 | service httpd reload | systemctl reload httpd.service |
实例
# 进行 cup 电源治理服务
> systemctl stop cups.service
#禁止 cups 服务开机启动
> systemctl disable cups.service
#查看 cups 服务状态
> systemctl status cups.service
#从新设置 cups 服务开机启动
> systemctl enable cups.service
罕用的系统命令
systemctl 命令 | 阐明 |
---|---|
systemctl | 列出所有的零碎服务 |
systemctl list-units | 列出所有启动 unit |
systemctl list-unit-files | 列出所有启动文件 |
systemctl list-units –type=service –all | 列出所有 service 类型的 unit |
systemctl list-units –type=service –all grep cpu | 列出 cpu 电源管理机制的服务 |
systemctl list-units –type=target –all | 列出所有 target |
systemctl list-unit-files –type=socket | 列出所有可用零碎套接口 |
systemctl 非凡的用法
systemctl 命令 | 阐明 |
---|---|
systemctl is-active [unit type] | 查看服务是否运行 |
systemctl is-enable [unit type] | 查看服务是否设置为开机启动 |
systemctl mask [unit type] | 登记指定服务 |
systemctl unmask [unit type] | 勾销登记指定服务 |
原文链接:https://rumenz.com/rumenbiji/…
微信公众号: 入门小站
正文完