Guide to linux boot sequence

=Boot Sequence=
 * 1) bootloader
 * 2) linux kernel
 * 3) inittab
 * 4) * /etc/inittab
 * 5) rc script (differs depending on which linux distribution
 * 6) init
 * 7) Background processes (network, system logging, cron, ...)
 * 8) * kernel modules
 * 9) ** by udev, kudzu, or hardcoded
 * 10) login
 * 11) * For graphical: See Graphical
 * 12) * For text mode: See Text Mode

Bootloader
Grub and lilo are the most popular bootloaders. They can load any OS any bootable drive or partition. They also pass kernel parameters to the Linux kernel.

Configuration Files:
 * /boot/grub/grub.conf

Configuration:
 * See: Howto configure Grub
 * See: Howto configure lilo

Kernel
The linux kernel boots up using the kernel parameters sent by the bootloader. The only other configuration to the kernel is done when compiling the kernel.


 * See: Howto use Linux kernel parameters
 * See: Howto compile the Linux kernel

inittab
After the kernel is loaded the first script to be run is inittab. This sets the runlevel, how to shutdown and use Ctrl-Alt-Del. It also sets the login program and executes the rc script.

Configuration File:
 * /etc/inittab

Configuration:
 * See: Howto configure inittab

rc script (sysinit)
The rc scripts differ from distribution to distribution, but they all do the same basic thing. They load the desired kernel modules and run the init scripts for the runlevel. The init scripts load the desired background processes, and are added or removed to each runlevel. The main rc script is generally not changed and init scripts and kernel modules are set by a program or setting file.

Main rc script: Configuration:
 * for Redhat Linux:   /etc/rc.d/rc.sysinit
 * for Gentoo Linux: /sbin/rc sysinit
 * Howto configure the Linux init system

init scripts
The init script run basic background processes, or programs. They are started by sysinit at boot up, however they can be started, stopped and restarted at any time.

Examples of init scripts: anacron, crond, famd, vsftpd, httpd, sendmail

Init scripts location:
 * /etc/rc.d/init.d/ or /etc/init.d/

Init scripts enabled/disable for each runtime (not recommended).
 * /etc/rc.d/rc[0-6].d/


 * Add/remove programs (recommended):
 * for Redhat Linux: chkconfig
 * for Gentoo Linux: rc-update

Text Mode
For Graphical Login See Graphical Login Mode Below

After login the start up scripts depend on what's the default shell. Theses scripts are standard shell scripts.

Bash
Shell scripts automatically loaded for a login terminal. Listed in the order they are executed.
 * /etc/profile
 * Gentoo: /etc/profile.d/*.sh
 * /etc/bash/bashrc or /etc/bashrc
 * ~/.bash_profile
 * if( ~/.bash_profile doesn't exists )
 * ~/.bash_login
 * if( ~/.bash_login doesn't exists )
 * ~/.profile
 * ~/.bashrc

~/.bash_logout is executed when a login terminal is logging out

For a non-login terminal(i.e. xterm, aterm) Listed in the order they are executed.
 * /etc/bash/bashrc
 * ~/.bashrc


 * Howto configure bash startup scripts

csh
Shell scripts automatically loaded for a login terminal. Listed in the order they are executed.
 * /etc/csh.cshrc
 * /etc/csh.login
 * ~/.tcshrc
 * if ~/.tcshrc is not found
 * ~/.cshrc,
 * ~/.history
 * ~/.login
 * ~/.cshdirs

For a non-login terminal(i.e. xterm, aterm) Listed in the order they are executed.
 * /etc/csh.cshrc
 * ~/.tcshrc
 * ~/.cshrc


 * Howto configure csh or tcsh startup scripts

tcsh
Same as csh.

sh
login shells
 * /etc/profile
 * ~/.profile

logout: command or script specified using the *trap "command" 0

ksh
same as sh

zsh
Login shells
 * ~/.zshenv
 * ~/.zprofile
 * ~/.zlogin

Logout
 * ~/.zlogout

Interactive shell
 * ~/.zshenv
 * ~/.zshrc

rc
Login shells
 * ~/.rcrc

sash
Seems not to have any.

=Graphical Login Mode= ...