Linux shell startup

When you boot your system you will eventually end up staring at a shell prompt. This is of course what you have wanted - to get to command the machine. But what has happened before that - automatically? It would be sufficient to only know the present state, but everything was not right? Right?

So, you will have to know where to put the fix for the effect intended. And that is one reason why you might want to explore this shell startup site. Another reason is curiosity, and one is: "It's not broken but I want to fix it...Where is the neat cut&paste stuff?"

Briefly, what will happen in startup?

When you switch on your computer, some essential hardware like hard disks is configured by BIOS. Then, Linux kernel boots a way or another (LILO, Loadlin, boot disk...). It loads device drivers and sets up the operating system.

A kernel running alone is not nice to watch. The first process, started by kernel, is init. init is controlled by file /etc/inittab. Normally, system initialization scripts under /etc/rc.d are executed to get the system up and running with all daemons.

Then, depending on the runlevel some gettys are spawned, and maybe xdm. They provide you with login prompts. Once a user enters her login into getty, login is started to ask for a password and to start her shell according to /etc/passwd shell field.

Following this far? init -> getty -> login -> shell. Now, I am going to make an assumption everybody will not like: This further shell is Bourne Again SHell (bash), or compatible. This is presently de facto standard at least under Linux. (If you like/use another shell, I encourage you to write this kind of reference for it too, for me to link to or include here.)

bash startup

During login process, an interactive (ie. with user interaction) login shell instance of bash is started. It executes:

NOTE:For backwards compatibility, if ~/.bash_profile is not found (or is inproper), ~/.bash_login and ~/.profile are tried also.