第一个启动的进程 systemd

image.png 使用命令查看结构;

pstree

centos7 专属服务管理器 systemd

用systemctl命令探索systemd

systemctl list-units --type=service

image.png 使用说明: unit是服务单位; image.png

用systemctl来探索服务的背后

用systemctl向服务发出指令,比如启动,关闭,重启一个服务。

systemctl start sshd.service

同理可以关闭或者重启。 接下来我们用systemctl探索服务的背后

systemctl cat sshd.service

image.png systemctl cat+服务名称就可以查看一个服务的详细信息。 systemctl status+服务名称,用来查看一个服务当前的状态如何。 举个例子: image.png

systemctl提供一个重要的工具叫做:journalctl,用来统一记录所有unit的日志信息。

systemd的启动项设置

开机时启动

systemctl enable sshd.service

开机时禁止

systemctl disable sshd.service

查看哪些服务会开机启动,可以用如下命令:

systemctl list-unit-files|grep enabled

结合target概念加深理解运行级别

查询默认运行级别 image.png target就代表一组units。 所谓的运行级别,就是把一个target设置成了开机启动而已。