Linux boot process.

VedikaVedika
6 min read

Hello everyone!! Vedika here,Welcome back to another blog. In this blog, I will cover all the relevant points that have been covered in today's Linux Workshop, conducted byPranav Jambare e at Dr.Babasaheb Ambedkar Technological University, Lonere.

In today's session following topics are covered...

Booting Process.

ACL.

Processes.

Soo Let's start with booting process..

Booting process:

• The booting process is the sequence of steps that a computer system goes through when it is turned on or restarted.

• You turn on your computer, and it starts initializing hardware components l xxike the CPU, memory, and peripherals.

Stages of the Booting Process:

•BIOS

•MBR

•GRUB

•Kernel

•Init d / system.d

•Run level

BIOS :(Basic Input Output System)

•It performs a Power-On Self-Test to check if all hardware components are working correctly.

•It identifies and initializes various hardware devices, such as the CPU, memory, storage controllers, and peripherals.

•Then it loads MBR.

MBR (Master Boot Record)

•The Master Boot Record (MBR) is the information in the first sector of a hard disk or a removable drive.

•The MBR also includes a program that reads the boot sector record of the partition containing the OS to be booted.

•The storage capacity of MBR is 512 bytes.

GRUB (GRand Unified Bootloader)

•GRUB is a complete program for loading and managing the boot process.

•It is the most common bootloader for Linux distributions. A bootloader is the first software that runs when a computer starts.

•It loads the kernel of the operating system.

•GRUB takes the code from MBR and then Filesystem communicates with hardware components.

•File Path of GRUB:

/boot/grub2/grub.conf

Kernel :

•The Linux kernel is the foundation of the Linux computer operating system. A kernel is the lowest level of software that can interface with computer hardware.

•All Linux applications and servers also interface with the Linux kernel. All Linux distributions are based on the Linux kernel and use its services to implement various software functions.

•It is also responsible for initializing virtual devices into the system.

•It creates a root device and mounts it into Read Only Memory.

•It freezes the unused memory.

Init d / system.d

•The init daemon is the first process executed by the Linux Kernel and its process ID (PID) is always 1. Its purpose is to initialize, manage and track system services and daemons. In other words, the init daemon is the parent of all processes on the system.

•It mounts the file system(FS)

/etc/fstab.

•It initializes the services.

•It identifies the default target.

•System.d is a modern initialization system and service manager that has largely replaced Init.d in newer Linux distributions.

•Init.d stands for "Initialization Directory" and is based on the traditional System V init system. It is commonly found in older Linux distributions.

Run level:

•It is a specific mode in which a computer's operating system starts up.

•This command is used to display current runlevel

who -r

•This command is used to initialize given runlevel

init 5

•It is used to set default to multiuser target

systemctl set-default multi-user.target

•It is used to display default target

systemctl get-default
#Following are the Runlevels
0 - Halt state poweroff.target

1 - Single user mode / rescue.target

2 - Mutliuser mode without networking

3 - Mulituser mode with networking

4 - User Definable

5 - GUI graphical.target

6 - Reboot.target

• ACL (Access Control List)

•ACL (Access Control List) is a security feature that allows you to set permission on files and directories beyond the traditional owner/group/other permissions.

•With ACL, you can set permission for individual users or groups providing a finer level of control access over files and directories.

•This is useful in a situation where you need to give access to a specific user or group without changing the default permission of a file or directory.

To set an ACL:

ACLs can be set using the syntax-

setfacl -m u:<username>:<permissions> <directory_name>

command, which allows administrators to add, modify, or remove ACL entries on files and directories.

The syntax-

getfacl <filename/dir_name>

the command is used for viewing ACLs on a file or directory.

To remove the ACLs, we use the syntax-

 setfacl -x u:<username>: <filename> .

Example-

 setfacl -m u:testuser:rwx TestACL/
then,

ls -ld

O/P- drwxrwxr-x+ 2 root root 4096 Jul 18 12:20 TestACL/

then,

getfacl TestACL/

O/P- # file: TestACL

# owner: root

# group: root

user::rwx
user::testuser::rwx

group::r-x

mask::rwx

other::r-x
then,setfacl -x u:testuser: TestACL/ //To remove a single user

then again,

getfacl TestACL/

O/P- user::rwx

group::r-x

mask::r-x

other::r-x

then,
setfacl -b TestACL/ //To remove all users

then again,

O/P- getfacl TestACL/

user::rwx

group::r-x

other::r-x

•Processes

•A program/command when executed, a special instance is provided by the system to the process. This instance consists of all the services/resources that may be utilized by the process under execution.

•Each process operates independently, having its memory space, execution context, and system resources.

States of Processes

•Created: The process is being set up and initialized but has not yet started executing.

•Ready: The process is loaded into the main memory (RAM) and is waiting for the CPU to be assigned to execute.

•Running: The process is actively using the CPU and executing its instructions.

•Waiting: The process is waiting for an event to occur, such as an input/output (I/O) operation, user input, or the completion of another process.

•Terminate: This is the final state of a process when it completes its execution or is forcefully terminated.

Types of processes:

Parent process: A parent process is a process that creates another process (called the child process).

•A perfect example will be your terminal and your bash shell; when you open your terminal, your bash shell is started as well.

Child process: A child process is created by a parent process in an operating system using a fork() system call.

•A child process is created as a copy of its parent process.

The child process inherits most of its attributes.

If a child process has no parent process, then the child process is created directly by the kernel.

Orphan process: An orphan process is a child process whose parent process has terminated before it did.

•Zombie process: A zombie process is a terminated child process that has completed its task, but its exit status is still needed by its parent. Although it no longer executes, it remains in the process table until the parent retrieves its exit status.

PID - Process ID

USER - User who initiated a particular process

PR - Priority

NI - NIC value

VIRT - Virtual memory

RES - Reserved memory

SHR S - Shared memory

%CPU - CPU uses

%MEM - Memory uses

TIME + COMMAND

•To see top commands

#Syntax- ps -ef|grep top

•To see gnome

#Syntax- ps -ef|grep gnome

•The command

#Syntax- nice -n -5 top is used to launch the 'top' command with a specific process priority level.

•The command

#Syntax- renice -5 Pid

is used to modify the priority of an existing process.

•The command

#Syntax- kill -19 Pid

allows you to send signals to processes, requesting them to terminate gracefully.

•terminate -15

•resume -18

•suspend -19

•jobs - To see the background processes.

Thank you!!!

10
Subscribe to my newsletter

Read articles from Vedika directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vedika
Vedika