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.
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.
|Determine the First Process in Your System
|Root or Sudo Privileges
|Ubuntu, Manjaro, Fedora, etc.
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=
$ ps --no-headers -o comm 1
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
Either, you can use the file command to output the real process.
$ file /sbin/init
Alternatively, you can use the stat command to find the real process with more information.
$ stat /sbin/init
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.
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!