1 systemd PID1
tengel edited this page 2024-03-20 11:55:03 -05:00

Test if PID 1 is systemd

$ sudo stat -c %N /proc/1/exe
or
# stat -c %N /proc/1/exe


Arch: '/proc/1/exe' -> '/usr/lib/systemd/systemd'
U16+: '/proc/1/exe' -> '/lib/systemd/systemd'
U14-: ‘/proc/1/exe’ -> ‘/sbin/init’
EL7+: ‘/proc/1/exe’ -> ‘/usr/lib/systemd/systemd’
EL6-: `/proc/1/exe' -> `/sbin/init'
DEB9+: '/proc/1/exe' -> '/lib/systemd/systemd'

One liner:

[[ $(sudo stat -c %N /proc/1/exe | grep -q systemd) ]] && echo "False" || echo "True"