This article will show you three methods for determining whether your Linux system is using systemd or another init system.
If you are unfamiliar with this term, check the following section; otherwise, skip to the next section.
What are Init and SystemD in Linux?
The init is the first (or parent) process with “PID=1” that is triggered by the kernel, and this process handles the rest of the (child) processes in your system. If somehow the system fails to load it, you will experience the state called “Kernel Panic”.
Since the release of System V init (the first commercial system designed to run on init), the SysV init system has been the most popular until the introduction of SystemD.
The SystemD released to outcome some setbacks exist in init (read our article on ‘init’ vs ‘systemd’ in Linux), the most highlighted was the lack of parallel processing on system boot.
Currently, while I was writing this article, most of the popular systems ran on SystemD, and in this article, you will learn to determine whether your system uses it or not.
Tutorial Details
Description | Determine the First Process in Your System |
Difficulty Level | Low |
Root or Sudo Privileges | No |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | ps, pstree |
Internet Required | No |
Determine the First Process in Your System
The first method is only applicable if your system is running on systemd; the second method works on any system; and the third method is uncertain (check the section to know).
Method 1: Extracting the PS Command Output
The following command will filter the command section from the ps command output for the first process (as you know, the first is always the init).
$ ps -p 1 -o comm=
#OR
$ ps --no-headers -o comm 1
Output:
If your system is running on systemd, you will get it in the result; however, different systems might output some random text.
Method 2: Following the Symbolic Link in the PS Output
As you already know, init is the first process with “PID = 1
“, so check the first process output using the ps command.
$ ps 1
Output:
As you can see from the above picture, the command section holds the “/sbin/init
” path; unfortunately, this is not an absolute but rather a symbolic link to your actual init process.
Either, you can use the file command to output the real process.
$ file /sbin/init
Output:
Alternatively, you can use the stat command to find the real process with more information.
$ stat /sbin/init
Output:
Method 3: Using the Pstree Command
This method varies depending on the system: if they have the pstree utility, then check the process tree to see if your system is running on systemd or not.
$ pstree
Output:
And here comes the end of all methods.
The above mentioned methods are the easiest and most efficient ways to determine whether your system is running on systemd or not.
If you have any other way to determine this, then do let me know in the comment section.
Till then, peace!
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.