[#]: subject: "How to Find Systemd or Any Other init System in Linux" [#]: via: "https://www.debugpoint.com/systemd-or-init/" [#]: author: "Arindam https://www.debugpoint.com/author/admin1/" [#]: collector: "lkxed" [#]: translator: "geekpi" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " 如何在 Linux 中查找 Systemd 或任何其他 init 系统 ====== **你可以通过以下方式确定你的 Linux 发行版中是否正在运行系统或任何其他 init 系统。** 第一个进程在你启动 Linux 发行版时开始,称为 init(初始化的缩写)。它的进程标识符为 1(即 pid=1)。基于 Unix 的系统中的所有进程和应用程序都是这个 init 进程的直接后代。 根据功能和特性,存在不同类型的初始化进程。例如,[systemd][1]、Runit、OpenRC、sysVinit 等。其中,systemd 是最流行和最现代的一种,被包括 Ubuntu 和 Fedora 在内的所有现代 Linux 发行版使用和采用。 与传统的基于 Unix 的 init 系统相比,Systemd 及其性能一直存在争议。但这是另一篇文章的主题。 让我们看看如何确定在 Linux 发行版中运行的是 systemd 还是任何其他 init 系统。 ### systemd 还是什么 init 系统? 不幸的是,没有直接的命令可以找到它。你可以从初始化进程 id=1 追溯它,它基本上是到 `/sbin/init` 的符号链接,即 pid=1。 使用 `[strings][2]` 命令打印嵌入在二进制文件 `/sbin/init` 中的文本并使用以下命令搜索 init。 ``` strings /sbin/init | grep init ``` **示例 1**:在下面的输出中,它是一个运行 Debian(通过 Peppermint OS)的 sysVinit 系统。如你所见,它清楚地显示了 init 进程名称。 ``` strings /sbin/init | grep init ``` ![显示使用 init 而不是 systemd 的示例][3] 如果在上述同一个系统中找到 systemd,那么不会有任何条目。因此,你可以得出结论,你正在运行 sysvinit 而不是 systemd。 **示例 2**:如果你在 systemd 系统中运行上述命令,你可以在输出的第一行轻松看到 systemd 及其版本。 ``` strings /sbin/init | grep systemd ``` ![显示它使用 systemd 的示例][4] **示例 3**:你也可以尝试使用 `pstree` 命令打印进程树,它应该会显示第一个进程名称。它应该是 systemd 或 init,如下例所示。 ``` pstree ``` ![pstree 显示使用 systemd][5] ![pstree 显示使用 init][6] 这就好了。这样你就可以轻松找出你的发行版是使用 systemd 还是其他的。 -------------------------------------------------------------------------------- via: https://www.debugpoint.com/systemd-or-init/ 作者:[Arindam][a] 选题:[lkxed][b] 译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://www.debugpoint.com/author/admin1/ [b]: https://github.com/lkxed [1]: https://www.debugpoint.com/tag/systemd [2]: https://linux.die.net/man/1/strings [3]: https://www.debugpoint.com/wp-content/uploads/2022/11/example-showing-the-init-is-used-and-not-systemd.jpg [4]: https://www.debugpoint.com/wp-content/uploads/2022/11/example-showing-it-uses-systemd.jpg [5]: https://www.debugpoint.com/wp-content/uploads/2022/11/pstree-is-showing-systemd-is-used.jpg [6]: https://www.debugpoint.com/wp-content/uploads/2022/11/pstree-is-showing-init-is-used.jpg