Skip to main content

Timeline for Detect init system using the shell

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Dec 28, 2016 at 19:59 history edited zzeroo CC BY-SA 3.0
added 166 characters in body
Oct 21, 2014 at 0:06 comment added terdon @psmears if it also works for some systemd systems, that is indeed better (but not mentioned in this answer). I just tested on a Debian running sysvinit, and three Ubuntus (10.04,12.04 and 14.04, all running upstart) and file /sbin/init returned "executable" on all systems. It also returns the same on a CentOS 5.8, a SLES 10, an Ubuntu 8.04, basically every single system I can get my hands on. So, as far as I can tell it doesn't even work for upstart and Ubuntu.
Oct 20, 2014 at 21:46 comment added psmears @terdon: On systems (RHEL, Fedora) running systemd, it returns "symbolic link to...systemd"; on systems (Ubuntu) running upstart it returns "symbolic link to upstart"; on systems (RHEL, Ubuntu, Debian) running SysV init it returns "executable". While that's hardly a comprehensive survey, and this method is clearly not 100% foolproof, it's clearly much closer to "works for at least the major distros" rather than "only upstart and Ubuntu"!
Oct 8, 2014 at 14:17 comment added terdon Exactly, so your solution seems to only work if one happens to be using upstart and Ubuntu.
Oct 8, 2014 at 14:14 comment added zzeroo Sorry for this confusion, I mean Debian (wheezy) /or Ubuntu (14.10.). Output on debian: file /sbin/init /sbin/init: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, BuildID[sha1]=0x8c68a736c6a4e6fadf22d5ac9debf11e79c6bdcd, stripped means we use SYSV here. Output for ubuntu is shown in my answer.
Oct 7, 2014 at 12:53 comment added terdon What system did you test it on? There's no such thing as Debian/Ubuntu and this does not work on Debian. Did you try it on Ubuntu?
Oct 7, 2014 at 12:40 review Low quality posts
Oct 7, 2014 at 12:55
Oct 7, 2014 at 12:27 review First posts
Oct 7, 2014 at 12:31
Oct 7, 2014 at 12:23 history answered zzeroo CC BY-SA 3.0