justlinux.com
Sat, 20-Mar-2010 06:20:03 GMT
internet.com
Forum: Registered Users: 73709, Online: 131
nhfs Here you can view your subscribed threads, work with private messages and edit your profile and preferences Registration is free! Calendar Find other members Frequently Asked Questions Search Home Home

Help File Library: Using SysVinit


Written By: Tigger

The /etc/inittab file contains the info needed for the system to boot and what to do in certain cases. The default runlevel is set here and the system runlevel is determined by this setting or if you have passed a specific runlevel at the lilo prompt ('linux 3' will start the system in runlevel 3).

All of the files in the rc#.d directories are just links to a script in /etc/rc.d/init.d. Upon initialization of the system, rc.sysinit is run and spawns off the appropriate runlevel by respawning the script /etc/rc.d/rc # (where # is the runlevel # that it determined from the default in /etc/inittab or from being passed to it from the lilo prompt). 'rc' runs the K* links first and then the S* links. As you can see, S seems to stand for start and K seems to stand for kill (you Unix and Linux vets will forgive me if I am wrong ;) )

Basically, 'rc' runs the link as follows:

/etc/rc.d/rc#.d/K##service stop
for the K ones and
/etc/rc.d/rc#.d/S##service start
for the S ones.

The reserved runlevels are 0, 1, and 6. The user runlevels are 2 to 5. Most distributions usually have the lower runlevels as text modes and the higher ones as X modes (i.e., they load xdm, gdm, or kdm to give you a GUI login screen). Runlevels 2 to 5 are not always the same from one distribution to another.

When you issue the halt command or shutdown -h now, rc runs in the rc0.d directory. A system halt is also known as switching to runlevel 0. When you issue the reboot command or shutdown -r now, it does the same but rc runs in the rc6.d directory. A reboot is known as switching to runlevel 6. Those of us, who through tinkering may have accidentally messed something up and need to boot into 'linux single' mode or runlevel 1, know that this is the 'fix what you messed up' mode. The most popular reason for this is to change back your 'root' password to something you know.

This whole process is referred to as SysVinit. Most distributions either init this way or have the ability to do so. All the distributions based on Red Hat init this way and Debian is only different in the location of the service scripts. The actual script for the individual services are in /etc/rc.d/init.d for Red Hat and variants or /etc/init.d for Debian and variants.

Many distributions have their own GUI tools to edit the different runlevels and you should check with your individual distribution if you do not want to do it manually.

You can add the runlevel links automatically with a program called chkconfig (at the CLI). This will work as long as the original startup/shutdown script is in /etc/rc.d/init.d with the rest of them.

Usage is as follows:

chkconfig --add service
chkconfig --del service

Or you can do it really manually as follows:

cp service /etc/init.d

Select which runlevel you want it run in and go to that directory

cd /etc/rc.d/rc#.d

Now create the link to run it and remember that rc selects them in the order that they are displayed when you list the directory.

ln -s /etc/rc.d/init.d/service S99service

Most scripts you add will be at the end and that is what the 99 means. I hope this sheds some light on the SysVinit process for all of you.


internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
internet.commerce
Be a Commerce Partner












The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers