Introduction to Linux concepts, processes and operations- Abdulrahman Olamilekan

Introduction to Linux concepts, processes and operations

Share This Post

Outline

By the end of this tutorial, you should be able to;

  1. Understand Linux startup operations and boot processes.
  2. Identify the differences between partitions and filesystems on a Linux system.

Linux startup operations and boot processes.

The linux boot process is a series of operations involved when initialising the system, it includes all series of steps involved from the power on of the machine, to when the system user interface becomes fully operational.

The diagram below shows the operations involved in a Linux os boot process.boot-process.png

BIOS

The computer BIOS(Basic Input/Output system) checks and initializes all the computer hardware and ensure all of the hardwares are fully operational. This operational of hardware testing is called POST(power on self test). The BIOS software is stored on a ROM chip, located on the motherboard.

Bootloader

The boot loader has two distinct stages:

For systems using the BIOS/MBR method, the boot loader resides at the first sector of the hard-disk, which is known as the master boot record – MBR.

  1. For the first stage, the boot loader takes over the boot process, and search for a bootable partition such as GRUB.
  2. The boot loader loads the Linux kernel into memory(RAM), and turn over execution process to the kernel.

For systems using the Extensible Firmware Interface(EFI)/Unified Extensible Firmware Interface (UEFI) method:

  1. For the first stage, the boot loader read its boot manager data, to determine which application is to be launched and from where.
  2. The firmware launches the application e.g GRUB as defined in the boot manager data

User login prompt

The init starts a number of text-mode login prompts. These enables the user type in their username and password, to eventually get a command shell.

The linux kernel

The boot loader loads both the kernel and an initial RAM-based file system (initramfs) into the memory so it can be used by the kernel.

linux-kernel.png

Initial RAM disk

initramfs filesystem image contains programs and binary files that perform all actions needed to mount the proper root filesystem and device drivers for mass storage controllers with a facility called udev(user device). After successful mount of the filesystem, the mount program instructs the operating system of the availability of the filesystem, and assigns a particular mount point to it, in the overall hierarchy of the system. If this communication/operation is successful, the initramfs program is cleared from the RAM, and the init program (sbin/init) in the root filesystem is executed. The init programs handles the final mounting and pivoting of the real root file system, needed by the Operating system.

initramfs.png

sbin/init – parent process

Once the kernel has set up all its hardware and mounted the root file system, the kernel runs /sbin/init, which is the initial process needed to start other processes and get the system running. Besides starting the system, init is responsible for shutting down the system cleanly.

The boot process is important in that, it allows the Linux user to intervene at any step and customise/configure the behaviour of the system to suit a specific need.

Startup alternatives

The two main startup alternatives developed were;

  • Upstart
  • Systemd

Systems with systemd start up faster than those with the earlier init methods, because systemd replaces a series of sequential steps with aggressive parallel processing technique, which allows multiple processes to be initiated simultenously.

With this approach, /sbin/init now points to /lib/systemd/systemd i.e systemd takes over the init process.

One systemd command is systemctl, which is used for basic service operations in the command line. The following are a brief description of it’s various uses;

  • Starting, stopping, restarting a service on a currently running systemCOPYCOPYCOPYCOPY$ sudo systemctl start|stop|restart mongodb
  • Enabling or disabling a system service from starting up at system bootCOPYCOPYCOPYCOPYsudo systemctl enable|disable mongodb

Boot logs

The boot logs contains all the processes loaded and initialised during the boot process, the boot log information is contained in a file called dmesg located in the /var/log directory. The /var/log directory contains all the log files present on a system.

To show the content of the dmesg file, run the following command in the terminal;COPYCOPYCOPYCOPY

dmesg | less

orCOPYCOPYCOPYCOPY

cat /var/log/dmesg
Screenshot 2022-09-05 at 21.00.50.png

Linux Filesystems

Think of a refrigerator that has multiple shelves and can be used to store various items in an organised manner. The same concept applies to the filesystem, where different computer related data is stored in a human-readable format.

Different types of filesystems in Linux

  • Conventional disk filesystems e.g ext3, ext4, ntfs etc.
  • Flash storage filesystems e.g ubifs, yaffs, etc.
  • Special purpose filesystems e.g procfs, sysfs, debugfs, etc.

Partition and Filesystems

Partition is a section of the hard-disk, used for specific operations.

Filesystem is a method used for storing/finding files in the hard-disk, usually specific to a partition.

One can think of a partition as a container in which filesystem resides, although filesystem can span across multiple partition and linked together using symbolic link.

The Linux system stores important files according to a standard layout called the Filesystem Hierarchy Standard (FHS). Unit OS, uses ‘/’ character to separate paths (unlike windows, which uses ‘\’), and does not have drive letters e.g E: or C: used in windows OS. Mounted drives and removable media devices are mounted as directory on the Linux filesystem. USB drives, CDs and DVDs will show up as mounted on the /run/media/<your username>/disklabel directory or/media` for older Linux distributions.

Screenshot 2022-09-06 at 09.35.52.png

All Linux filesystem names are case-sensitive, so /boot, /Boot, and /BOOT represent three different directories (or folders).

To get a feel of how the home directory Filesystem Hierarchy looks like, run the command below;COPYCOPYCOPYCOPY

tree -aCd -L 2 /

More To Explore

general tech

An Overview of Node.js Package Managers (npm and yarn)

Node.js is a powerful platform for building server-side applications, but one of the most important aspects of Node.js development is managing dependencies. Fortunately, Node.js has