LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2015, 09:15 AM   #1
willc86
Member
 
Registered: Dec 2014
Posts: 55

Rep: Reputation: Disabled
question about run level programs and how the OS know what to run


Hey guys, I am a little confused about run level programs. (concerning centos)

I know when the system boots up the orders will be

bios
MBR
GRUB
kernel
init
runlevel

to my understanding - etc/init looks at /etc/inittab
then where is the run level located?
is it /etc/rc.d/rc0.d...
/etc/rc.d/rc1.d
/etc/rc.d/rc2.d
are these run level programs?

if so, what about /etc/init.d ? doesnt that also execute run level programs?

and how does it know what to start? where does it look

thanks guys just a bit confusing where what looks for what
 
Old 04-29-2015, 10:48 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,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
/etc/init.d is a link to /etc/rc.d/init.d on RHEL/CENTOS and similar distros.
This directory contains the init scripts but they are not run automatically from this directory.

Instead you make links in the rc?.d directories where ? is the run level desired (e.g. rc1.d = run level 1, rc5.d = run level 5 etc...) The files in the run level directories have the format S###<script>, K###<script> where the S scripts are start and the K are stop (kill). The ### is the order number (e.g. 009 starts before 123). If two scripts have the same ### they are processed alphabetically (e.g. S124startfun would run after S124havefun. The <script> is the same name as the base script you see in /etc/init.d.

Last edited by MensaWater; 04-30-2015 at 09:41 AM.
 
Old 04-29-2015, 11:00 AM   #3
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 3,331
Blog Entries: 1

Rep: Reputation: 690Reputation: 690Reputation: 690Reputation: 690Reputation: 690Reputation: 690
Bear in mind that init is replaced with systemd for many distros. Which negates a lot of the traditional ways.

In the days of old the run level would be defined in /etc/inittab. And the /etc/rc#.d/ contains some files, the S##_ ones are for things to run at startup. The K##_ ones for the shutdown. rcS.d is single user, rc0.d is startup rc6.d is shutdown, and the rc1.d to rc5.d are most of the functional stuff that runs at boot in terms of non-systemd services. In days of old run level 3 was a multi-user system at the console, and run level 5 was a multi-user system with a GUI. But debian does gui at run level 2 for some time now. So it depends on the distro, not the history. Roughly as I'm not a system admin, but I've dealt with said locations for personal customizations over the years.

Each distro is unique enough these days you really have to delve into the code base to "know" what's going on. egrep can help identify things. Check your /var/log/ stuff and egrep the log entries to see what generates them, then egrep for the startup stuff that launches the thing that generated the log entry. And on up the tree of stuff. Or find some relevant and hopefully up to date documentation that humanizes it. Likely to find, not likely to be up to date.
 
Old 04-29-2015, 11:31 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853Reputation: 4853
Quote:
Originally Posted by Shadow_7 View Post
rc0.d is startup rc6.d is shutdown
Just to correct that, runlevel 0 is for shutting down the system, runlevel 6 is for rebooting the system.
 
Old 04-30-2015, 09:46 AM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
Originally Posted by Shadow_7 View Post
Bear in mind that init is replaced with systemd for many distros.
The OP was talking specifically about what he saw in CentOS init script setups. CentOS is a binary compile from RHEL source.

RHEL7 (and therefore CentOS7) uses systemd but RHEL6/CentOS6 and earlier still use SysV init as I described. For now systemd can still run your SysV init scripts on RHEL7 but will give you a warning every time to let you know it isn't really designed for systemd.

There has been much gnashing of teeth about the move to systemd but since it is already in the later releases of some distros folks will need to embrace it.
 
Old 04-30-2015, 04:10 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
And note: init scripts run on RHEL7/CentOS7 will not necessarily work...

They run in parallel with systemd startups, and assume that the network is actually ready - so if you have failures with some network services, make sure you have "NetworkManager-wait-online" target enabled. This causes NetworkManager to delay sending a "ready" signal to systemd. without it, it appears that systemd assumes the network is ready whenever NetworkManager is started, and that isn't always true.

If you have services that depend on yet other services... that may be tricky to get working.
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Small tip: use run level 2 as a customized run level 3 to boot faster Didier Spaier Slackware 3 01-14-2015 07:14 AM
Can't switch to TTY or run level 3 from run level 5 reemfz Fedora 3 06-01-2009 09:06 AM
How to enter graphical mode (run level 5) command line (run lenel 3) edmondgyampoh Linux - Newbie 3 05-15-2009 07:33 PM
set your default run level so you will boot to a default run level - vga console Adam555 Linux - Newbie 1 01-21-2008 05:55 PM
Run Level 3 Font Size Question (NEWBIE) NoZlmAn72 Linux - Newbie 3 03-17-2005 02:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:41 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration