question about run level programs and how the OS know what to run
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
/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.
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.
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.
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.