5

I am on Ubuntu 16.04, and am following allong "Starting and Stopping" services chapter of the Linux Bible (9th edition). I am trying to find what type of init daemon I have (init or systemd) which requires I find what process has PID of 1. However, I get 2 different results depending on how I run the command...

webmaster@my-site:~$ ps -p1
  PID TTY          TIME CMD
    1 ?        00:00:29 systemd
webmaster@my-site:~$ ps -F -p1
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root         1     0  0  9420  5336   0 Feb23 ?        00:00:29 /sbin/init

It says systemd for PID1 after running the first command, but /sbin/init for PID1 after running the second command.

2 Answers 2

2
                        GRUB(GRand Unified Bootloader)
                                       |                                                          
                                       |
                                       |                                                  
                                       V
                                     Kernel
                                       |
                                Hardware check
                                       |
                            -----------------------
                            |init processes start |
                            -----------------------
                                      /|\
                                     / | \
                            SysVinit   |  systemd
                        init scripts   |
                                    Upstart

Let me try to explain with the diagram above. Now in Ubuntu it started with SysVinit, then Upstart, and finally Systemd. Each of these will handle the initprocess which begins all things Linux and Ubuntu in general.

Now Ubuntu is gradually moving away from Upstart and into Systemd and is the current init controller on Ubuntu Xenial. The init process starts all things (or most, as the kernel has its own process that are unrelated to init), but what handles or controls that init process is either SysVinit, Upstart, or Systemd depending on your version of Ubuntu. In your case it's the newer Systemd. But bare in mind that you will also see remnants of the old system, where commands such as initctl, service etc still play.

So to get the initial system functions or services up and running new Ubuntu now uses systemd the replacement for init daemon of old. But for backward compatibility init still runs in the background.

According to man ps, passing an -F flag causes the command arguments to be printed out. So in this case the command is seen with:

ps -p 1

#Result
PID TTY          TIME CMD
1 ?        00:00:02 systemd

Then to see the the arguments passed to that command:

ps -F -p 1

#Result
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
root         1     0  0 46414  6336   1 05:48 ?        00:00:02 /sbin/init splash

So ps -p 1 ==> command, and ps -F -p 1 ==> arguments passed to it. Long story short -F Extra full format, seeing more information that is related to the ps -p 1 or systemd command. What you see is an underlying init process run by systemd on Ubuntu Xenial. Take note of the TIME:00:00:02, which is the same for both systemd and /sbin/init in both forms of ps.

Please look at this page and you will see why /sbin/init shows up when -F option is used. Systemd runs with PID 1 as /sbin/init.

Source:

man ps

https://wiki.ubuntu.com/SystemdForUpstartUsers

1
  • Interesting. However, still confused as to why (or how) the ps command is outputting different values for the cmd column...As in, what is 'ps' doing differently between these two calls...
    – codecitrus
    Mar 16, 2017 at 22:30
2

For Ubuntu 16.04, default init is systemd

~$ ls -l /sbin/init
lrwxrwxrwx 1 root root 20 Oct  3 20:44 /sbin/init -> /lib/systemd/systemd

systemd is the one really running. -F option makes ps print the exact command line (including arguments) used to launch it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .