linuxnewbie.org.gif
Tuesday, 12-Dec-2000 10:32:05 EST
Newbized Help Files articles discussion board bookshelf sensei's log advertising info
The SysVinit NHF
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 fro 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(ie. 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 know 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. For 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:

copy the script to /etc/init.d

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.

TonyB


Would you like to have your article published online? Send them in to newfiles@linuxnewbie.org

The Linux Channel at internet.com
Linux Planet
Linux Today
Linux Central
Linuxnewbie.org
PHPBuilder
Just Linux
Linux Programming
Linux Start
BSD Today
Apache Today
Enterprise Linux Today
BSD Central
All Linux Devices
SITE DESCRIPTIONS
[-What's New-]
Order a Linuxnewbie T-Shirt
Easy Webcam NHF
Directory Navigation NHF
Installing Snort 1.6.3 on SuSE 6.x-7.x
Customizing vim
The SysVinit NHF
Installing ALSA for the VT82C686 integrated sound
USB Creative Video Blaster II for Linux
Configuring the Intellimouse Explorer in XFree86 V4+
The beginnings of a distro NHF
Getting Past Carnivore?
Getting and Installing PGP
Getting your ATI Rage 128 Working
How to create a multiple partition system
Using Fdisk
Introduction to Programming in C/C++ with Vim
Adding a Hard drive in Linux -- In five steps
Installing ALSA for the Yamaha DS-XG Sound Card
Getting your Diamond Rio Mp3 Player to work with Linux
Bash Programming Cheat Sheet
Installing NVIDIA Drivers for Mandrake
Setting up Portsentry
Hard Drive Speed Tweak for Linux
Sensei's Log
Chat room
Join: Linuxnewbie.org SETI Black Belts!
Send in your news
Click the image to add Linuxnewbie.org to your MyNetscape Page
[-LNO Newsletter-]

[-Archive-]
The beginnings of a distro NHF
Connecting to the Internet using KPPP
Getting your SBLive to work
Unreal Tournament NHF
LWE Day 2 Pictures
LWE Day 1 Pictures
The LNO FAQ!
WoW (Words of Wisdom)
Other sites news
What is Linux?
What is Linux? part deux (ups & downs)
Search newsgroups
The List
ALS Report
Feedback Form
jobs.linuxtoday.com.gif
Match: Format: Sort by:
Search:
[-Quick Links-]

Copyright 2000 internet.com Corp. All Rights Reserved. Legal Notices Privacy Policy

internet.com.gif