A guide to System V Init

So here we go again. After you have exorcised all of the daemons that were haunting your system, you might be interested in all of the boring processes that occur when booting your linux. It might seem a bit mystical right now, but it’s all quite simple. But, let’s skip the usual introductionary phrases and aim directly for the head!

Wake up, you…you…penguin!

At the very beginning lets clear out that what we will discuss here concernes only System V Init, so if you’re interested in reading more about BSD Init you’ll have to do it quietly somewhere else. As most of linux distributions use System V Init (ie, Red Hat, SuSE and etc) I’ll make it not only the pin point of this article but devote this entire article to it! Everything you can read in this article has been written with SuSE linux in mind, so please notice that some things may vary from distribution to distribution.

System V Init uses run levels for determening modes of starting the system and as usual, you’ll find that most linux distributions use different systems of run level settings, so it may vary from distribution to distribution. Basically, there are 7 run levels, ranging from 0 to 6. In every distribution run level 0 stands for halt, it stops the system, and run level 6 stands for reboot, and of course it kicks you system with an old John Wayne boot.Other run levels are 1, wich usually but not necessarily stands for single user mode, usually used for administrating the system and other admin related stuff. Other run levels, such as 2, 3, usually stand for full multiuser mode, with or without graphical login. So, let’s pretend you wish to switch login from ASCII one to a graphical, and are running SuSE linux, you would type:

init 3

And, providing you have succesfully configured your GUI, you’ll see a graphical login. Simple, and without any annoying Windows type neccessity for rebooting the system. And, if you wih to return to your ASCII login, just type:

init 2

There, you got the point. Now, if you wish to halt, or reboot your system you can always switch to run level 0 or 6. Feel free to experiment, nothing bad can happen. If you wish to find out more about the command init, and it’s function type ‘man init’.

The default runlevel is decided in /etc/inittab. You should have a line close to the top like:


From this, you’d look in the second column and see that the default runlevel is 3. If you want to change it, you can edit /etc/inittab by hand and change the 3 to any other number (ie 2).

If you should happen to have any problems with changing default run level you can always start linux by typing ‘linux single’ at LILO prompt. Then you can fix it, and continue working.

Now, the init function basically calls scripts and starts processes. It does so by calling scripts from /etc folder called rc.d. In /etc/rc.d you’ll find all of the files and folders necessary for starting the system. It will look somewhat like this.

Of course, there are other files to find there, but we’re only interested in these folders. As you can guess, rc3.d contains all the scripts that are started in run level 3, and so on. Now, for the interesting part, go to any of these and you shold find something like this.

Mess, right? Actuall, it’s very simple and easy. You see, all the scripts and links to them are located here, and marked for the Init to recognize what to do. If you look closer you’ll notice that all the links are started with a capital letter K or S, and are followed by a number. The letter S stands for start and the letter K stands for stop the script. The number after the letters signifies the importance of the process, and the smaller the number the bigger is the priority of the process. As you can see, numbers don’t have to be unique, you can have more of the same, like above numbers 19 and 21, but it’s not recomended to have them if the process should start and end before every other. You might also want check out the init.d folder also in /etc/rc.d. Sometimes the location of all these folders may vary from distribution to distribution, but it is always located somewhere inside /etc.

So change and remodel it to your desire, add links to your scripts, but beware not to mess up things to much. You can swith off all the processes you don’t need, and if you’re not sure which you need and don’t, make a boot disk, so if anything goes wrong you have a way back. If you fancy yourself a GUI tool for enabling and disabeling these you can alway use Sys V Init Editor, available with KDE, or run level editor, for an very easy and smooth fixing up.

Additionaly, you can alway check up with ‘ps’, or ‘top’ to make sure that the process is terminated, also combined with netstat if any network stuff related.

There. Keep experimentin’!

Share this