The Linux Boot Process

Here, we are seeking to understand what exactly happens when a Linux machine is powered on.

Depending on your hardware configuration, the firmware that is responsible for system startup will either be some flavor of BIOS( Basic Input/Output System) or UEFI( Intel’s Unified Extended Firmware Interface).

This firmware will take stock of the hardware environment and look for a device that has a Master Boot Record(MBR) . The MBR contains partitions and filesystem information telling the firmware where the boot drive is.

GRUB will present you with a startup menu where you can choose the software that will load. The GRUB menu will let you choose between booting into a recent OS image installed on the system, running a memory test or other advanced options.

The Advanced menu may allow you to boot in recovery mode or select older kernel images. All kernel images are usually displayed on the GRUB menu.

This is usually important if a system upgrade has resulted in major issues.

When you press “e” when a particular image is highlighted, you will be able to edit boot parameters. You should however take great care when it comes to spelling and syntax of boot parameters. A small mistake on the parameters can leave your PC unbootable or bootable but highly insecure.

Troubleshooting Boot Failure

When a Linux system fails to boot, the first place you should probably look when diagnosing is the system logs.

The following files located in /var/log should shed some light; kern.log, boot.log and dmesg

Some of these log files may not exist on other distributions especially those running newer Systemd process manager.


One of the greatest features of Linux is the ability for multiple users to log in and work simultaneously on the same server.

But there are times when you need to be alone on the system. Like when something has gone horribly wrong and you do not need other users to make it worse.

The concept of runlevels specifies how to use the system by controlling which services are running. It defines whether your OS will be available for everyone or just a single admin user, or whether it will provide network services or graphic desktop support.

A common use of runlevels is to distinguish a system that offers only a text console from one that offers a GUI. Most end-user system run GUI but servers are more secure and perform better without it.

Below are the standard runlevels and their designated numbers:

0: Halt

1: Single User Mode

2: Multi-User without NFS

3: Full Multi-User Mode

4: Unused

5: X11

6: Reboot

There are 7 runlevels specified by integers 0 through 6.

Runlevels 0 and 6 specify transitional states of shutdown and reboot respectively

When a Linux system boots, it begins the init process which starts all the other processes and is responsible for placing the system in the default runlevel

Runlevel 0

It halts the system.

It is a transitional state used to shutdown the system quickly.

It should never be the default runlevel because the system will never come up. It will always shutdown immediately the init process is initiated.

Runlevel 1

This is the single-user mode.

It is also called the maintenance mode. Remote logins and networking are disabled.

It is used for system tasks that must be performed with no user activity.

One can boot directly into single user mode by passing parameters to the kernel at boot time.

To change the default runlevel at boot time, edit the line that line that boots your kernel and add a 1 or the word single to the end of the line to indicate single user mode

Runlevel 2

Multi-User mode.

On Debian-Based system, this is the default runlevel.

On Redhat-based systems, this the multi-user mode without NFS and GUI

Runlevel 3

This is the default Multi-user mode on Redhat-based systems which runs everything except the X-Window system.

Runlevel 4

Typically unused.

Runlevel 5

On RHEL systems, this is the full multi-user mode with GUI login.

It is like runlevel 3 but with X11 started.

Runlevel 6

This is also a transitional device used to reboot the system.

It should not be set as the default runlevel since the system will forever reboot.

Runlevels are completely configurable by the end user. They can be invoked from the command-line using either init or telinit

Running init 6 or telinit 6 for instance will reboot your system.

The shutdown command can also be used to halt and reboot the system

shutdown -h now will halt the system immediately

shutdown -r now will reboot the system immediately

shutdown -h 5 will halt the system after 5 minutes

If there are any other users logged into the system, the shutdown command will send a warning message to their terminals. This can also be achieved using the wall command.

Previously, runlevels are controlled by a daemon called init and the system’s default runlevel is was stored in a file called /etc/inittab.

This was however replaced by the Upstart process manager . Under Upstart, the runlevels are defined by files placed in directories under /etc with names like rc0.d , rc1.d , rc2.d.

The default runlevel in Upstart is defined in /etc/init/rc-sysinit.conf file

Upstart however was replaced with systemd process manager

Systemd focuses more on processes than runlevels. You can find the configurations in etc/systemd/system/

Startup Scripts in /etc and the init process

When a Linux system starts, a number of scripts in /etc are run to initially configure the system.

The system initialization process differs among different Linux distributions.

/etc/rc.sysinit or /etc/init.d/rcS

On RHEL systems, rc.sysinit is a system initialization script that is launched by init at boot time and it does some critical tasks to prepare the system for use such as mounting filesystems.

The script is designed to run before any system dameons are started.


This script is called after all other init scripts have been executed.

It contains local customization affecting system startup.

Unlike rc.sysinit, changes made on rc.local are not lost after a system upgrade

This file might however not be present in all distributions.


This is a script used to switch between different runlevels.


The job of starting and stopping system services (daemons) is handled by files and symbolic links located in /etc/init.d

This directory contains the startup/shutdown scripts for each service on the system.

These services normally run on the backgrounnd.

The scripts have a standard basic form and take which include start, stop, status, restart, reload

Determining, setting and changing your system’s runlevel

To determine your system’s runlevel, use the runlevel command.

# runlevel

N 5

The above output is from a system that booted in runlevel 5

# runlevel

3 5

The above output is from a system that booted in runlevel 3 but is now on runlevel 5

To change the system runlevel, use the init or telinit command

1 Comment

  1. This is really interesting, You’re a very skilled blogger. I have joined your feed and look forward to seeking more of your great post. Also, I’ve shared your site in my social networks!

Leave a Reply

Your email address will not be published. Required fields are marked *