LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-04-2016, 12:58 AM   #1
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 364

Rep: Reputation: 38
Question Detect the init system used in a Linux distro


In order to find out which init system a linux distro is using what I do is check the /sbin/init file.

I would start by checking
Code:
readlink /sbin/init
. If it is pointing to systemd or upstart, I get my answer. If it is not a symbolic link I would query which package the file belongs to: on a debian/ubuntu I would do
Code:
dpkg -S /sbin/init
and on a CentOS/RHEL/Fedora I would do
Code:
rpm -qf /sbin/init
Am I missing something? Is my process of detecting the init process flawed?

Last edited by the_gripmaster; 03-04-2016 at 01:00 AM.
 
Old 03-04-2016, 06:55 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
For RHEL5/6/7 simply doing the "rpm -qf /sbin/init" should be sufficient (i.e. even if a symbolic link some package installed that link):

RHEL5:
rpm -qf /sbin/init
SysVinit-2.86-17.el5

RHEL6:
rpm -qf /sbin/init
upstart-0.6.5-13.el6_5.3.x86_64

RHEL7:
rpm -qf /sbin/init
systemd-219-19.el7_2.4.x86_64

Last edited by MensaWater; 03-04-2016 at 07:30 AM.
 
1 members found this post helpful.
  


Reply

Tags
init, systemd, sysvinit, upstart


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to Install GRUB which can detect three Linux Distro monojeffrey Linux - Desktop 14 01-13-2016 05:39 AM
Ubutnu won't boot. Error: Target file system doesn't have /sbin/init. No init found. Zeljka_Lin Linux - Newbie 9 05-02-2011 06:56 AM
Redhat linux9.0:System hangs,if gives init 3 or init 4 Sailaja Reddy Linux - Newbie 4 09-16-2004 03:19 AM
linux system call to detect changes in a directory lucianomx Programming 4 06-05-2002 06:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration