Every Linux Admin or DevOps Engineer should know what happens when a Linux system boots. It's a very popular Interview Question as well.
Every time you power on your Linux PC, it goes through a series of stages before finally displaying a login screen that prompts for your username or password.
There are 3 high level stages of a typical Linux boot process.
Once power is initially applied to the pc it runs the POST (Power On Self Test) that is a component of the BIOS (Basic I/O System).
POST is the part of BIOS whose task is to confirm that the pc hardware functioned properly.
Bootloader Stage-
Once d POST is complete & d coast is clear, d BIOS probes d MBR (Master Boot Record) for d bootloader & disk partitioning info.
MBR is a 512-byte code dat is located on d 1st sector of d harddrive which is usually /dev/sda or hda depending on ur hard drive arch
There are 3 main types of bootloaders in Linux: LILO, GRUB, and GRUB2. The GRUB2 bootloader is the latest and primary bootloader in modern Linux distributions and informs our decision to leave out the other two which have become antiquated with the passage of time.
GRUB2 stands for GRand Unified Bootloader version 2. Once the BIOS locates the grub2 bootloader, it executes and loads it onto the main memory (RAM).
The grub2 menu allows you to do a couple of things. It allows you to select the Linux kernel version that you’d want to use.
GRUB parameterand their Meaning -
root->
use 3rd partition on the primary disk by setting it as (hd0,3)” in GRUB 2
kernel ->
use kernel located at “/vmlinuz” with kernel parameter: “root=/dev/hda3 ro“
initrd ->
use initrd/initramfs image located at “/initrd.img“
Kernel Stage -
Kernel is d core of any Linux system. It interfaces the PC’s hardware with d underlying processes. The kernel controls all d processes on your Linux system.
Kernels are present in /boot directory in a self-extracting, compressed format to save space.
It is placed there along with an initial RAM disk image, and device maps of the hard drives.
After the selected kernel is loaded into memory it first extracts itself from the compressed version then loads systemd, and turns control over to it.
Starting Systemd -
The kernel finally loads Systemd, which is the replacement of the old SysV init. Systemd is the mother of all Linux processes and manages among other things mounting of file systems, starting and stopping services to mention just a few.
Systemd uses the /etc/systemd/system/default.target file to determine the state or target that the Linux system should boot into.
For a desktop workstation (with a GUI) the default target value is 5 which is the equivalent of run level 5 for the old SystemV init.
For a server, d default target is multi-user.target which corresponds to runlevel3 in SysV init
Here’s a breakdown of d systemd targets: poweroff.target (runlevel 0): Poweroff /Shutdown d system rescue.target (runlevel 1): launches a rescue shell session
multi-user.target (runlevel 2,3,4): Configures d system to a non-graphical (console) multi-user system. graphical.target (runlevel 5): Set d system to use a graphical multi-user interface with nw services. reboot.target (runlevel 6): reboots the system.
To check the current target on your system, run the command:
$ systemctl get-default
First, systemd mounts the filesystems as outlined by /etc/fstab, together with any swap files or partitions. At now, it will access the configuration files set in /etc, together with its own.
Systemd handles boot and services management processes using “targets”.
The very first target executed by systemd is /etc/systemd/system/default.target, to work out the state or target, into which it should boot the host. The default.target file is just a symbolic link to the actual target file.
Everything you need to know about Virtualization, VMs , Containers, Pods, Clusters ..
A Mega Thread 👇
What is Virtualization?
Virtualization is the act of dividing shared computational resources: CPU, RAM, Disk, and Networking into isolated resources that are unaware of the original shared scope.
What is a virtual machine?
A VM is a virtual env that functions as a virtual computer system with its own CPU, memory, nw interface, & storage, created on a physical hw system (located off- or on-prem).
It uses sw instead of a physical computer to run programs & deploy apps.
traceroute tracks the route packets take across an IP network on their way to a given host.
It assists you in troubleshooting nw connectivity issues from your Destination to a Remote destination by using echo packets (ICMP) to visually trace the route.
The syntax -
The cmd traceroute <x> (x here being an IP or hostname) is d most basic version & it will begin to send packets to d designated target. This result will allow u to trace d path of d packets sent from ur machine to each of d systems b/n u & ur desired destination.
Cybersecurity is a way of protecting the network, computers, and other electronic gadgets from cybercriminals. The Malicious attackers might delete, modify or leak confidential information posing a huge threat to a business or an individual.
Iptables is a command-line firewall utility for Linux. It monitors traffic from & to ur server using tables.
These tables contain sets of rules, called chains, that will filter incoming & outgoing data packets.
When someone tries to establish connection to and from your system iptables immediately looks for a rule in its list to match it and If it doesn’t find a matching one, it resorts to the default action (either DROP or Accept).
Rsync, or Remote Sync, is a fast, versatile and free command-line tool that lets you transfer and sync files and directories to local and remote destinations in an efficient and secure way. .
Why use Rsync?
When copying or moving large no. of files using tools like cp and mv may leave ur data in inconsistent state with part of it still in the original location and part of it in the target destination in case of any interruptions.