Discovering the concept of linux

Discovering the concept of linux

Linux Workshop :- day 6

Hello everyone ;

I am Teertha Darekar ;

Welcome back to my day 6 blog of linux Workshop conducted by Pranav Jambare sir.

CONTENTS :-

Booting process

ACL

Processes

let's start :-

--> Booting process

  • The linux boot process is the sequence of stages the operating system goes through when it is started.

  • During the boot process the system's hardware is initialized , the bootloader is loaded , the kernel is loaded into memory , system service are created , and the user interface is presented .

Stages Of Booting :-

BIOS .

  • BIOS stands for basic Input / output system .

  • It performs some system integrity checks ; seraches , loads and executes the boot loader program .

  • Once the bootloader program is detected and loaded into the memory , BIOS controls it .

  • In simple terms , BIOS loads and executes the MBR boot loader.

MBR .

  • MBR stands for Master Boot Record .

  • It iis located in the 1st sector of the bootable disk . It is less than 512 bytes in size .

  • This has three componentes :-

  1. Primary boot loader info in 1st 446 bytes

  2. Partition table info in the next 64 bytes

  3. mbr validation check in the last 2 bytes It contains info about GRUB ; MBR loads and executes the GRUB boot loader.

GRUB .

  • GRUB stands for Grand Unifield Bootloader .

  • If you have multiple kernel images installed on your system you can choose which one to be executed .

  • It knows about the file system .

  • The GRUB configuration file is :-

    /boot/grub/grub.conf

  • GRUB loads and executes kernel and initrd images.

Kernel .

  • Kernel executes the /sbin/init program .

  • Since init was the 1st program to be executed by linux kernel , it has the process id (PID) of 1 .

  • initrd is used by the kernel as a temporary root file system until the kernel is booted and the natural root file system is mounted

Init.d / system.d .

  • Looks at the /etc/inittab file to decide the linux run level.

  • init identifies the default init level from /etc/inittab and uses that to load all appropriate programs

Run level .

  • When the linux system booms up , you might see various service getting started ; Those are run level programs .

  • who -r :- It is used to display current run level

Run levels:-

0 :- Halt state poweroff.target

1 :- Single user mode / Rescue.target

2 :- Multi user mode without networking

3 :- Multi user mode with networking

4 :- user definable

5 :- GUI graphical.target

6 :- Reebot.target

--> ACL(Access Control Lists)

  • Access Control Lists (ACLs) provide access control to directories and files.

  • ACLs can set read, write, and execute permissions for the owner, group, and all other system users.

  • An ACL consists of a set of rules that specify how a specific user or group can access ACL enabled files and directories.

  • A regular ACL entry specifies access information for a single file or directory.

  • A default ACL entry is set on directories only, and specifies the default access information for any file within the directory that does not have an access ACL.

To set ACL :-

setfacl -m u:[username]:[permissions] [directory name]/

To remove ACL :-

setfacl -x u:[username]:[diractory name]/

To know the info of ACL

getfacl dirname/

Show the long listing format of just the directory.

ls -ld [file name]

--> Processes

  • A process is a task that your Linux machine is currently working on.

  • For example, when you open a browser, your machine creates a process for it.

  • The process is created when a command is to be executed so, it can be called a running instance of a program in execution.

Processes States :-

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.

There are four types of Process in Linux

  1. Parent process: The process created by the user on the terminal. All processes have a parent process, If it was created directly by user then the parent process will be the kernel process.

  2. Child process: The process created by another process (by its parent process). All child processes have a parent process.

  3. Orphan process: Sometimes when the parent gets executed before its own child process then the child process becomes an orphan process. The orphan process have “Init” process (PID 0) as their PPID (parent process ID)

  4. Zombie process: The processes which are already dead but shows up in process status is called Zombie process. Zombie processes have Zero CPU consumption.

PID :- Process ID

USER :- user name

PR :- priority

NI :- Nice value

VIRT :- Virtual memory

RES :- Reserved memory

SHR :- Shared memory

S :- State

%CPU :- CPU usage

%MEM :- Memory usage

TIME :- Total CPU time

COMMAND :- command name

To see the Top command :-

ps -ef|grep top

nice command :-

Used to give priority.

It is an integer that ranges from -20 to +20.

nice -n -5 top

renice command :-

The renice command alters the nice value of one or more running processes.

renice -5 [pid]

To kill :-

kill -9 [pid]

To Terminate :-

 kill -15 [pid]

To Resume :-

kill -18 [pid]

To suspend :-

kill -19 [pid]

To check status :-

jobs

Foreground process :-

fd %[job number]

Thank you .....