CH 6 The LINUX Operating
System
Previous Question Paper
1. Explain the 6 stages of Linux Booting Process.
2. Write a note on types of Processes in LINUX.
3. Explain the functions of Kernel in Linux.
4. Explain salient features of Linux.
5. Explain basic elements or components of Linux
6. What is Kernel? Explain its functions
7. Explain any.6 shell commands with example.
How Linux Kernel Boots?
Many processes are running in the background when we press the system’s power
button. It is very important to learn the booting process to understand the working of any
operating system. Knowing how the kernel boots is a must to solve the booting error. It
is a very interesting topic to learn, let us start with the basics. A simplified read of the
boot method is given below:
Stages of Linux Boot Process:
1. The machine’s BIOS (Basic Input/Output System) or boot microcode
hundreds and runs a boot loader.
2. Boot loader finds the kernel image on the disk and loads it into memory, to
start the system.
3. The kernel initializes the devices and their drivers.
4. The kernel mounts the basis file system.
5. The kernel starts a program referred to as init with a method ID zero
6. init sets the remainder of the system processes in motion.
7. For some purpose, init starts a method permitting you to log in, typically at the
top or close to the top of the boot sequence.
Booting Process
Startup Message:
Traditional UNIX operating system manufactures several diagnostic messages upon
boot that tell you regarding the boot method. The messages come back initially from the
kernel and so from processes and low-level formatting procedures that init starts.
However, these messages aren’t pretty or consistent, and in some cases, they aren’t
even terribly informative. Additionally, hardware enhancements have caused the kernel
to start a lot quicker than before the messages flash by therefore quickly, it may be
tough to check what’s happening. As a result, most current Linux distributions do their
best to cover boot medical specialty with splash screens and different varieties of filler
to distract you whereas the system starts.
Kernel Initialization and Boot Options:
1. CPU examination
2. Memory examination
3. Device bus discovery
4. Device discovery
5. Auxiliary kernel system setup
6. Root filesystem mount
7. User-space begin.
The first 2 steps aren’t too exceptional, however, once the kernel gets to devices, the
question of dependencies arises. As an example, the disk device drivers might rely on
bus support and SCSI system support. In general, you won’t need to worry regarding
the dependencies, except that some necessary parts are also loadable kernel modules
instead of a part of the most kernel.
Kernel Parameters:
When the Linux kernel starts, it receives a group of text-based kernel parameters
containing some further system details. The parameters specify many alternative kinds
of behavior, like the number of diagnostic outputs the kernel ought to manufacture and
device driver–specific choices. The Ro parameter instructs the kernel to mount the
basis file system in read-only mode upon user area begins. This normal read-only mode
ensures that fsck can safely check the basis file system before attempting to do
something serious. When the check, the bootup method remounts the basis file system
in read-write mode.
Boot Loader Tasks:
● Select from multiple kernels.
● Switch between sets of kernel parameters.
● Provide support for booting different operating systems.
Bootloaders have become significantly advanced since the origin of the Linux kernel,
with options like command-line history and menu systems, however, a basic want has
perpetually been flexibility in kernel image and parameter choice. One stunning
development is that some wants to have really diminished. As an example, as a result
of being able to perform associate emergency or recovery boot from a USB device, you
seldom need to worry about manually getting into kernel parameters or going into
single-user mode. Current bootloaders supply a lot of power than ever, which may be
notably handy if you’re building custom kernels or simply wish to tweak parameters.
Boot Loader Overview:
● GRUB – A near-universal normal on Linux systems, with BIOS/MBR and
UEFI versions.
● LILO – One of the primary Linux bootloaders. ELILO could be a UEFI version.
● SYSLINUX – It may be organized to run from many alternative styles of file
systems.
● LOADLIN – Boots a kernel from DOS.
● System-boot a straightforward UEFI boot manager.
● core boot – A superior replacement for the computer BIOS which will
embody a kernel.
● Linux Kernel EFISTUB A kernel plug-in for loading the kernel directly from
associate EFI/UEFI System Partition.
● EFI Linux – A UEFI boot loader meant to function as a model and reference
for different UEFI boot loaders.
Introduction and Work of Few Bootloaders mentioned above:
1) GRUB:
GRUB stands for Grand Unified Boot Loader. One of GRUB’s most vital capabilities
is file system navigation that enables straightforward kernel image and configuration
choice.
● Upon finding the boot code, the BIOS hundreds and executes it. This is often
wherever GRUB begins.
● The GRUB core hundreds.
● The core initializes. At now, GRUB will currently access disks and file
systems.
● GRUB identifies its boot partition and hundreds of configurations there.
● GRUB offers the user an opportunity to vary the configuration.
● GRUB executes the configuration after a timeout or user action.
● In the course of execution of the configuration, GRUB might load further code
within the boot partition. a number of these modules are also preloaded.
● To load and execute the kernel GRUB executes boot commands.
2) LILO (Linux Loader):
It was the first bootloader developed for Linux, still some users use it today. If we
compare it to the GRUB bootloader it is quite simple and primarily used with BIOS
system. To install it on Linux system one can install it using package manager like apt
or yum. After installation it can be easily configured by editing its configuration file
located at `/etc/lolo.conf`.
3) SYSLINUX:
It is lightest among other bootloaders; it can perform booting from removable media
such as CDs or USB drives. Its key feature is that it supports different file systems, a
command-line interface and the ability to boot from multiple devices. For example, to
install SYSLINUX on a USB drive we can configure SYSLINUX setting by editing its
configuration file located in `/syslinux/syslinux.cfg`.
Conclusion:
It is very important to know how Linux kernel boots and to know that one must know
how to solve boot problems. The Linux boot process has several stages that include
BIOS, boot loader, kernel initialization, device and driver initialization. While kernel is
responsible for specifying various behaviors and device drivers-specific option whereas
bootloader is responsible for providing flexible kernel image and parameter selection.
We discussed the most common boot loader and overall, we can conclude that it is
important for system administrators, developers and single users using Linux operating
systems.
—----------------------------------------------------------------------------------------------------------------
2.
Kernel modules — The Linux Kernel documentation (linux-kernel-labs.github.io)
—----------------------------------------------------------------------------------------------------------------
3.
What is Kernel?
In computer science, Kernel is a computer program that is a core or
heart of an operating system. Before discussing kernel in detail, let's first
understand its basic, i.e., Operating system in a computer.
Operating System
An operating system or OS is system software that works as an interface
between hardware components and end-user. It enables other programs to
run. Each computer system, whether it is desktop, laptop, tablet, or
smartphone, all must have an OS to provide basic functionalities for the
device. Some widely used operating systems are Windows, Linux, MacOS,
Android, iOS, etc.
What is Kernel in Operating System?
○ As discussed above, Kernel is the core part of an OS (Operating
system); hence it has full control over everything in the system. Each
operation of hardware and software is managed and administrated by
the kernel.
○ It acts as a bridge between applications and data processing done at
the hardware level. It is the central component of an OS.
○ It is the part of the OS that always resides in computer memory and
enables the communication between software and hardware
components.
○ It is the computer program that first loaded on start-up the system
(After the bootloader). Once it is loaded, it manages the remaining
start-ups. It also manages memory, peripheral, and I/O requests from
software. Moreover, it translates all I/O requests into data processing
instructions for the CPU. It manages other tasks also such as memory
management, task management, and disk management.
○ A kernel is kept and usually loaded into separate memory space,
known as protected Kernel space. It is protected from being
accessed by application programs or less important parts of the OS.
Functions of a Kernel
A kernel of an OS is responsible for performing various functions and has
control over the system. Some main responsibilities of Kernel are given
below:
○ Device Management
To perform various actions, processes require access to peripheral
devices such as a mouse, keyboard, etc., that are connected to the
computer. A kernel is responsible for controlling these devices using
device drivers. Here, a device driver is a computer program that
helps or enables the OS to communicate with any hardware device.
A kernel maintains a list of all the available devices, and this list may
be already known, configured by the user, or detected by OS at
runtime.
○ Memory Management
The kernel has full control for accessing the computer's memory. Each
process requires some memory to work, and the kernel enables the
processes to safely access the memory. To allocate the memory, the
first step is known as virtual addressing, which is done by paging or
segmentation. Virtual addressing is a process of providing virtual
address spaces to the processes. This prevents the application from
crashing into each other.
○ Resource Management
One of the important functionalities of Kernel is to share the resources
between various processes. It must share the resources in a way that
each process uniformly accesses the resource.
The kernel also provides a way for synchronization and inter-process
communication (IPC). It is responsible for context switching between
processes.
○ Accessing Computer Resources
A kernel is responsible for accessing computer resources such as RAM
and I/O devices. RAM or Random-Access Memory is used to contain
both data and instructions. Each program needs to access the memory
to execute and mostly wants more memory than the available. For
such a case, Kernel plays its role and decides which memory each
process will use and what to do if the required memory is not available.
The kernel also allocates the request from applications to use I/O
devices such as keyboards, microphones, printers, etc.
Types of Kernel
There are mainly five types of Kernel, which are given below:
1. Monolithic Kernels
In a monolithic kernel, the same memory space is used to implement
user services and kernel services.
It means, in this type of kernel, there is no different memory used for user
services and kernel services.
As it uses the same memory space, the size of the kernel increases,
increasing the overall size of the OS.
The execution of processes is also faster than other kernel types as it does
not use separate user and kernel space.
Examples of Monolithic Kernels are Unix, Linux, Open VMS, XTS-400,
etc.
Advantages:
○ The execution of processes is also faster as there is no separate user
space and kernel space and less software involved.
○ As it is a single piece of software hence, it's both sources and compiled
forms are smaller.
Disadvantages:
○ If any service generates any error, it may crash down the whole
system.
○ These kernels are not portable, which means for each new
architecture, they must be rewritten.
○ Large in size and hence become difficult to manage.
○ To add a new service, the complete operating system needs to be
modified.
2. Microkernel
A microkernel is also referred to as μK, and it is different from a traditional
kernel or Monolithic Kernel. In this, user services and kernel services are
implemented into two different address spaces: user space and
kernel space. Since it uses different spaces for both the services, so, the
size of the microkernel is decreased, and which also reduces the size of the
OS.
Microkernels are easier to manage and maintain as compared to monolithic
kernels. Still, if there will be a greater number of system calls and context
switching, then it might reduce the performance of the system by making it
slow.
These kernels use a message passing system for handling the request from
one server to another server.
Only some essential services are provided by microkernels, such as defining
memory address spaces, IPC (Interprocess Communication), and process
management. Other services such as networking are not provided by Kernel
and handled by a user-space program known as servers.
One of the main disadvantages of monolithic kernels that an error in the
kernel can crash the whole system, can be removed in the microkernel. As in
a microkernel, if a kernel process crashes, the crashing of the whole system
can still be prevented by restarting the error-caused services.
Examples of Microkernel are L4, AmigaOS, Minix, K42, etc.
Advantages
○ Microkernels can be managed easily.
○ A new service can be easily added without modifying the whole OS.
○ In a microkernel, if a kernel process crashes, it is still possible to
prevent the whole system from crashing.
Disadvantages
○ There is more requirement of software for interfacing, which reduces
the system performance.
○ Process management is very complicated.
○ The messaging bugs are difficult to fix.
3. Hybrid Kernel
Hybrid kernels are also known as modular kernels, and it is the
combination of both Monolithic and Microkernels. It takes advantage of the
speed of monolithic kernels and the modularity of microkernels.
A hybrid kernel can be understood as the extended version of a
microkernel with additional properties of a monolithic kernel. These
kernels are widely used in commercial OS, such as different versions of MS
Windows.
It is much similar to a microkernel, but it also includes some additional code
in kernel space to enhance the performance of the system.
Hybrid kernels allow to run some services such as network stack in kernel
space to reduce the performance compared to a traditional microkernel, but
it still allows to run kernel code (such as device drivers) as servers in user-
space.
Examples of Hybrid Kernel are Windows NT, Netware, BeOS, etc.
Advantages:
○ There is no requirement for a reboot for testing.
○ Third-party technology can be integrated rapidly.
Disadvantages:
○ There is a possibility of more bugs with more interfaces to pass
through.
○ It can be a confusing task to maintain the modules for some
administrators, especially when dealing with issues such as symbol
differences.
4. Nanokernel
As the name suggests, in Nanokernel, the complete code of the kernel
is very small, which means the code executing in the privileged
mode of the hardware is very small. Here the term nano defines a kernel
that supports a nanosecond clock resolution.
Examples of Nanokernel are EROS etc.
Advantages
○ It provides hardware abstractions even with a very small size.
Disadvantages
○ Nanokernel lacks system services.
5. Exokernel
Exokernel is still developing and is the experimental approach for designing
OS.
This type of kernel is different from other kernels as in this; resource
protection is kept separated from management, which allows us to perform
application-specific customization.
Advantages:
○ The exokernel-based system can incorporate multiple library operating
systems. Each library exports a different API, such as one can be used
for high-level UI development, and the other can be used for real-time
control.
Disadvantages:
○ The design of the exokernel is very complex.
—------------------------------------------------------------------------------------------------------------------
Q. Write a note on types of Processes in LINUX.
Types of Processes
1. Parent and Child process: The 2nd and 3rd column of the
ps –f command shows process id and parent’s process id
number. For each user process, there’s a parent process in
the system, with most of the commands having shell as their
parent.
2. Zombie and Orphan process: After completing its
execution a child process is terminated or killed and
SIGCHLD updates the parent process about the termination
and thus can continue the task assigned to it. But at times
when the parent process is killed before the termination of
the child process, the child processes become orphan
processes, with the parent of all processes “init” process,
becomes their new pid.
A process which is killed but still shows its entry in the
process status or the process table is called a zombie
process, they are dead and are not used.
3. Daemon process: They are system-related background
processes that often run with the permissions of root and
services requests from other processes, they most of the
time run in the background and wait for processes it can
work along with for ex print daemon.
When ps –ef is executed, the process with? in the tty field
are daemon processes.
—-------------------------------------------------------------------------------
Q. Components of Linux System
Linux is one of popular version of UNIX operating System. It is open
source as its source code is freely available. It is free to use. Linux
was designed considering UNIX compatibility. Its functionality list is
quite similar to that of UNIX.
Components of Linux System
Linux Operating System has primarily three components
Kernel − Kernel is the core part of Linux. It is responsible for all
major activities of this operating system. It consists of various
modules and it interacts directly with the underlying hardware.
Kernel provides the required abstraction to hide low level
hardware details to system or application programs.
System Library − System libraries are special functions or
programs using which application programs or system utilities
accesses Kernel's features. These libraries implement most of
the functionalities of the operating system and do not requires
kernel module's code access rights.
System Utility − System Utility programs are responsible to do
specialized, individual level tasks.
Kernel Mode vs User Mode
Kernel component code executes in a special privileged mode called
kernel mode with full access to all resources of the computer. This
code represents a single process, executes in single address space
and do not require any context switch and hence is very efficient
and fast. Kernel runs each processes and provides system services
to processes, provides protected access to hardware to processes.
Support code which is not required to run in kernel mode is in
System Library. User programs and other system programs works in
User Mode which has no access to system hardware and kernel
code. User programs/ utilities use System libraries to access Kernel
functions to get system's low level tasks.
Basic Features
Following are some of the important features of Linux Operating
System.
Portable − Portability means software can work on different
types of hardware in same way. Linux kernel and application
programs supports their installation on any kind of hardware
platform.
Open Source − Linux source code is freely available and it is
community based development project. Multiple teams work in
collaboration to enhance the capability of Linux operating
system and it is continuously evolving.
Multi-User − Linux is a multiuser system means multiple users
can access system resources like memory/ ram/ application
programs at same time.
Multiprogramming − Linux is a multiprogramming system
means multiple applications can run at same time.
Hierarchical File System − Linux provides a standard file
structure in which system files/ user files are arranged.
Shell − Linux provides a special interpreter program which can
be used to execute commands of the operating system. It can
be used to do various types of operations, call application
programs. etc.
Security − Linux provides user security using authentication
features like password protection/ controlled access to specific
files/ encryption of data.
—--------------------------------------------------------------------
Q. Explain any.6 shell commands with example.
https://www.geeksforgeeks.org/basic-shell-commands-in-linux/
—-------------------------------------------------------------------------------