Linux Tutorial
Linux File/Directory Management
Linux Packaging And Compression
Vim Text Editor
Linux Text Processing
Linux Software Installation
Linux User/User Group Management
Linux Permission Management
Linux Filesystem Management
Linux Advanced Filesystem Management
Linux System Management
Linux Backup and Recovery
Linux System Service Management
Linux System Log Management
Linux Boot Management
LAMP/LNMP Environment
SELinux Management
In this tutorial, we will explore the Linux system startup process specifically for CentOS, a popular Linux distribution. The boot process consists of several stages, from powering on the hardware to loading the operating system and user applications.
CentOS uses systemd
as its init system, which is responsible for managing services and system states during the startup process.
1. BIOS (Basic Input/Output System) or UEFI (Unified Extensible Firmware Interface)
When you power on a computer, the BIOS or UEFI initializes and performs a series of hardware checks, known as the Power-On Self Test (POST). The BIOS/UEFI is responsible for detecting and configuring hardware components, such as the CPU, memory, and storage devices.
Once POST is complete, the BIOS/UEFI searches for a bootable device in the order specified in its configuration. Typically, the boot order includes options like the hard drive, USB drive, CD/DVD drive, and network boot.
2. Boot Loader (GRUB)
The boot loader is responsible for loading the operating system. CentOS uses GRUB (GNU GRand Unified Bootloader) as its default boot loader. The boot loader typically displays a menu that allows the user to select an operating system or kernel version. Once the user makes a selection or the boot loader times out, it proceeds to load the selected operating system.
3. Kernel Loading
The boot loader loads the Linux kernel into memory and passes control to it. The kernel is responsible for managing system resources, such as the CPU, memory, and devices. The kernel performs various tasks during startup, such as:
4. Init Process (systemd
)
After the kernel is loaded and initialized, it starts the init process, which is the first user-space process with a process ID (PID) of 1. CentOS uses systemd
as its init system. The init process is responsible for starting other system processes and services.
5. System Targets and Services
systemd
uses targets (instead of runlevels) to manage system states. Targets are groups of services that should be started or stopped together. Common system targets in CentOS include:
poweroff.target
: System halt (shutdown)rescue.target
: Single-user mode (maintenance mode)multi-user.target
: Multi-user mode with networking (text mode)graphical.target
: Multi-user mode with networking and graphical user interface (GUI)reboot.target
: System rebootDuring the startup process, systemd
starts the services required by the default target. By default, CentOS uses multi-user.target
or graphical.target
, depending on the system configuration.
To manage services in CentOS, you can use the systemctl
command. Some common systemctl
commands include:
sudo systemctl list-units --type service
sudo systemctl status service_name
sudo systemctl start|stop|restart service_name
sudo systemctl enable|disable service_name
6. User Login
Once the system services are started and the target is set, the user is presented with a login prompt. This can be either a text-based prompt in a virtual console or a graphical login screen provided by a display manager, such as GDM (GNOME Display Manager), LightDM, or SDDM (Simple Desktop Display Manager).
Viewing and analyzing CentOS boot logs:
/var/log/
directory, and commands like journalctl
can be used to analyze systemd logs.# Example: Viewing boot logs journalctl
Configuring services to start on boot in CentOS:
systemctl
to enable or disable services for automatic startup.# Example: Enabling a service to start on boot sudo systemctl enable servicename
Troubleshooting CentOS startup issues:
journalctl
and systemctl
are essential.# Example: Checking systemd logs journalctl -xe
Customizing the GRUB bootloader in CentOS:
# Example: Editing GRUB configuration sudo nano /etc/default/grub sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Managing systemd units during CentOS boot:
systemctl
command is used for this purpose.# Example: Listing enabled units sudo systemctl list-unit-files --type=service