Fundamentals 11 min read

Understanding Linux Boot Process: From Kernel Loading to User Login

This article explains the Linux boot sequence on Debian, covering BIOS handoff, kernel loading from /boot, the init process, runlevel configuration via /etc/rcN.d, startup script linking, three login methods, and how login and non‑login shells source configuration files such as /etc/profile and ~/.bashrc.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Understanding Linux Boot Process: From Kernel Loading to User Login

Loading the Kernel

After the BIOS hands control to the operating system, the kernel image located in /boot is read. Typical Debian /boot files include vmlinuz-3.2.0‑amd64, initrd.img-3.2.0‑amd64, and related configuration files.

$ ls /boot
config-3.2.0-amd64
initrd.img-3.2.0-amd64
vmlinuz-3.2.0-amd64
...

Starting the Init Process

The loaded kernel launches the first user‑space program /sbin/init, which becomes process ID 1. All other processes are descendants of this init process.

Determining the Runlevel

Init reads /etc/inittab to set the default runlevel (e.g., id:2:initdefault: means runlevel 2). Each runlevel (0‑6) has a corresponding directory /etc/rcN.d that lists the programs to start.

/etc/rc0.d
/etc/rc1.d
/etc/rc2.d
/etc/rc3.d
/etc/rc4.d
/etc/rc5.d
/etc/rc6.d

Files in these directories follow the naming pattern S<NN>program (start) or K<NN>program (kill), where NN determines execution order.

$ ls /etc/rc2.d
README
S01motd -> ../init.d/motd
S13rpcbind -> ../init.d/rpcbind
S14nfs-common -> ../init.d/nfs-common
S16rsyslog -> ../init.d/rsyslog
S16sudo -> ../init.d/sudo
S17apache2 -> ../init.d/apache2
S18acpid -> ../init.d/acpid
...

All entries are symbolic links to scripts in /etc/init.d, allowing a single copy of each script to serve multiple runlevels.

User Login

Once startup programs finish, the system presents a login interface. Three common login methods are:

Console login via getty and login (or PAM modules).

SSH login using sshd.

Graphical login via a display manager such as GDM.

Entering the Login Shell

After successful authentication, the user’s login shell (default bash on Debian) is started. Bash reads configuration files in a specific order depending on the login method.

~/.bash_profile
~/.bash_login
~/.profile

Only the first existing file among the three is sourced; it typically loads /etc/profile and then the user‑specific ~/.profile.

Opening a Non‑Login Shell

When a user opens a terminal after login, a non‑login shell is created. This shell does not read the login files but does source ~/.bashrc. Debian ensures ~/.bashrc is executed for all shells by adding the following snippet to ~/.profile (or ~/.bash_profile if it exists):

if [ -n "$BASH_VERSION" ]; then
  if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
  fi
fi

Thus, user customizations placed in ~/.bashrc are applied consistently, regardless of how the shell was started.

Additional Notes

Mac OS X also uses Bash as its default shell; it loads .bash_profile which in turn sources .bashrc, ensuring similar behavior for both SSH and graphical terminal sessions.

Boot process diagram
Boot process diagram
Kernel loading
Kernel loading
Runlevel directories
Runlevel directories
Init script links
Init script links
Login methods
Login methods
Shell types
Shell types
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

initDebianRunlevel
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.