0% found this document useful (0 votes)
38 views

Linux Theory

Uploaded by

arbazmadani25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Linux Theory

Uploaded by

arbazmadani25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

www.google.

com

Google Works Better on Chrome - Sync Chrome to You


Phone - The Official Browser of Google

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 OS.

Other application programs such as browser, word processor, audio & video player use
separate memory space known as user-space.

Due to these two separate spaces, user data and kernel data don't interfere with each
other and do not cause any instability and slowness.

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:
www.google.com

Google Chrome Browser - Use Chrome for Faster


Browsing - Google Chrome Keeps You Safe

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.

Microsoft Azure - Sponsored

Explore these Azure offerings


Confidently transform your business with expert
guidance – from planning to deployment

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.


ADVERTISEMENT

Linux History

Evolution of Computer

In earlier days, computers were as big as houses or parks. So you can imagine how difficult it
was to operate them. Moreover, every computer has a different operating system which made
it completely worse to operate on them. Every software was designed for a specific purpose
and was unable to operate on other computer. It was extremely costly and normal people
neither can afford it nor can understand it.

Evolution of Unix

In 1969, a team of developers of Bell Labs started a project to make a common software for all
the computers and named it as 'Unix'. It was simple and elegant, used 'C' language instead of
assembly language and its code was recyclable. As it was recyclable, a part of its code now
commonly called 'kernel' was used to develop the operating system and other functions and
could be used on different systems. Also its source code was open source.

Initially, Unix was only found in large organizations like government, university, or larger
financial corporations with mainframes and minicomputers (PC is a microcomputer).

Unix Expansion

In eighties, many organizations like IBM, HP and dozen other companies started creating their
own Unix. It result in a mess of Unix dialects. Then in 1983, Richard Stallman developed GNU
project with the goal to make it freely available Unix like operating system and to be used by
everyone. But his project failed in gaining popularity. Many other Unix like operating system
came into existence but none of them was able to gain popularity.
ADVERTISEMENT

Book Full Body Checkup at Home


Book Test Online. Get tested in 60 mins and Reports in One Day

Evolution of Linux

In 1991, Linus Torvalds a student at the university of Helsinki, Finland, thought to have a freely
available academic version of Unix started writing its own code. Later this project became the
Linux kernel. He wrote this program specially for his own PC as he wanted to use Unix 386 Intel
computer but couldn't afford it. He did it on MINIX using GNU C compiler. GNU C compiler is
still the main choice to compile Linux code but other compilers are also used like Intel C
compiler.

He started it just for fun but ended up with such a large project. Firstly he wanted to name it as
'Freax' but later it became 'Linux'.

He published the Linux kernel under his own license and was restricted to use as commercially.
Linux uses most of its tools from GNU software and are under GNU copyright. In 1992, he
released the kernel under GNU General Public License.

Linux Today

Today, supercomputers, smart phones, desktop, web servers, tablet, laptops and home
appliances like washing machines, DVD players, routers, modems, cars, refrigerators, etc use
Linux OS.

← Prev Next →
ADVERTISEMENT

www.google.com

The Official Browser of Google - Google Works Better


on Chrome Chrome: A Browser Just For You

Architecture of Linux
Let's first start with the basic knowledge of the Linux operating system.

Linux operating system


An operating system can be described as an interface among the computer hardware and the user of
any computer. It is a group of software that handles the resources of the computer hardware and
facilitates basic services for computer programs.

An operating system is an essential component of system software within a computer system. The
primary aim of an operating system is to provide a platform where a user can run any program
conveniently or efficiently.

On the other hand, Linux OS is one of the famous versions of the UNIX OS. It is developed to provide
a low-cost or free OS for several personal computer system users. Remarkably, it is a complete OS
Including an X Window System, Emacs editor, IP/TCP, GUI (graphical user interface), etc.

ADVERTISEMENT
Linux operating system history
ADVERTISEMENT

In 1991, the Linux history started with the starting of a particular project by the Finland student Linus
Torvalds for creating a new free OS kernel. The final Linux Kernel was remarked by continuous
development throughout the history since then.

ADVERTISEMENT

www.google.com

Google Chrome Keeps You Safe - Go Beyond


Browsing with Chrome - Chrome: A Faster
W T B

Linux was proposed by the Finland student Linus Torvalds in 1991.

HP-UX (Hewlett Packard) 8.0 version was published.

Hewlett Packard 9.0 version was published in 1992.

FreeBSD 1.0 version and NetBSD8 version was released in 1993.

Red Hat Linux was proposed in 1994. Caldera was detected by Ransom love and Bryan Sparks
and NetBSD 1.0 version published.

HP-UX 10.0 version and FreeBSD 2.0 version was released in 1995.

K Desktop Environment was established by Matthias Ettrich in 1996.

HP-UX 11.0 version was released in 1997.

The IRIX 6.5 version, i.e., the fifth SGI UNIX generation, Free BSD 3.0 version, and Sun Solaris 7
OS was released in 1998.

The Caldera System agreement with professional services division and SCO server software
division was released in 2000.

Linus Torvalds published the Linux version 2.4 source code in 2001.

Microsoft filed the Trademark collection against Lindows.com in 2001.

Lindows name was modified to Linspire in 2004.

The first publication of Ubuntu was published in 2004.

The openSUSE project started a free distribution from the community of Novell In 2005.

Oracle published its Red Hat distribution in 2006.


Dell begun laptop distribution with Ubuntu which was pre-installed on it in 2007.
ADVERTISEMENT
Linux kernel version 3.0 was released in 2011.

Linux-based android of Google insisted 75% of the market share of the Smartphone, based on
the number of phones exported in 2013.

Ubuntu insisted on 20000000+ users in 2014.

Architecture of Linux system

The Linux operating system's architecture mainly contains some of the components: the Kernel,
System Library, Hardware layer, System, and Shell utility.

1. Kernel:- The kernel is one of the core section of an operating system. It is responsible for each of
the major actions of the Linux OS. This operating system contains distinct types of modules and
cooperates with underlying hardware directly. The kernel facilitates required abstraction for hiding
details of low-level hardware or application programs to the system. There are some of the important
kernel types which are mentioned below:

Monolithic Kernel

Micro kernels

Exo kernels

Hybrid kernels

2. System Libraries:- These libraries can be specified as some special functions. These are applied for
implementing the operating system's functionality and don't need code access rights of the modules
of kernel.
3. System Utility Programs:- It is responsible for doing specialized level and individual activities.
ADVERTISEMENT
4. Hardware layer:- Linux operating system contains a hardware layer that consists of several
peripheral devices like CPU, HDD, and RAM.

5. Shell:- It is an interface among the kernel and user. It can afford the services of kernel. It can take
commands through the user and runs the functions of the kernel. The shell is available in distinct
types of OSes. These operating systems are categorized into two different types, which are the
graphical shells and command-line shells.

The graphical line shells facilitate the graphical user interface, while the command line shells facilitate
the command line interface. Thus, both of these shells implement operations. However, the graphical
user interface shells work slower as compared to the command-line interface shells.

There are a few types of these shells which are categorized as follows:

Korn shell

Bourne shell

C shell

POSIX shell

Linux Operating System Features


Some of the primary features of Linux OS are as follows:
ADVERTISEMENT

Portable: Linux OS can perform different types of hardware and the kernel of Linux supports
the installation of any type of hardware environment.

Open source: Linux operating system source code is available freely and for enhancing the
capability of the Linux OS, several teams are performing in collaboration.

Multiprogramming: Linux OS can be defined as a multiprogramming system. It means more


than one application can be executed at the same time.

Multi-user: Linux OS can also be defined as a multi-user system. It means more than one user
can use the resources of the system such as application programs, memory, or RAM at the
same time.

Hierarchical file system: Linux OS affords a typical file structure where user files or system
files are arranged.

Security: Linux OS facilitates user security systems with the help of various features of
authentication such as controlled access to specific files, password protection, or data
encryption.

Shell: Linux operating system facilitates a unique interpreter program. This type of program
can be applied for executing commands of the operating system. It can be applied to perform
various types of tasks such as call application programs and others.

ADVERTISEMENT

Microsoft Azure - Sponsored


Learn More

Explore these Azure offerings


ADVERTISEMENT

Drawbacks of Linux

Hardware drivers: Most of the users of Linux face an issue while using Linux. Various
companies of hardware prefer to build drivers for Mac or Windows due to they contain several
users than Linux. Linux has small drivers for peripheral hardware than windows.

Software alternative: Let's take the Photoshop example which is a famous tool for graphic
editing. Photoshop exists for Windows; however, it is not available in Linux. Also, there are
some other tools for photo editing but the Photoshop tool is more powerful as compare to
others. Another example is MS office which is not present for Linux users.

Learning curve: Linux isn't a very user-friendly operating system. Hence, it might be confusing
for many beginners. Getting begun with Windows is efficient and easy for many beginners;
however, understanding Linux working is complex.
We have to understand the command line interface and finding for newer software is a little bit
complex as well. When we face any issue in the OS, the searching solution is very problematic.
Also, there are various experts for Mac and Windows as compare to Linux.

Games: Several games are developed for Windows but unfortunately not for Linux. Because
the platform of Windows is used widely. So, the developers of the games are more interested
in windows.
Linux Operating System Applications
ADVERTISEMENT

Linux is a billion-dollar corporation nowadays. Thousands of governments and companies are using
Linux operating system across the world because of lower money, time, licensing fee, and
affordability. Linux can be used within several types of electronic devices. These electronic devices are
easily available for users worldwide. A few of the famous Linux-based electronic devices are listed
below:

Yamaha Motive Keyboard

Volvo In-Car Navigation System

TiVo Digital Video Recorder

Sony Reader

Sony Bravia Television

One Laptop Per child XO2

Motorola MotoRokr EM35 phone

Lenovo IdeaPad S9

HP Mini 1000

Google Android Dev Phone 1

Garmin Nuvi 860, 880, and 5000

Dell Inspiron Mini 9 and 12

Linux Distribution
It is an OS that is composed of a software-based collection on Linux kernel or we can say the
distribution includes the Linux Kernel. It is supporting software and libraries. We can obtain Linux-
based OS by downloading any Linux distribution. These types of distributions exists for distinct types
of devices such as personal computers, embedded devices, etc. Around more than 600 Linux
distributions are existed and a few of the famous Linux distributions are listed as follows:

Deepin

OpenSUSE

Fedora

Solus

Debian

Ubuntu

Elementary
Linux Mint
ADVERTISEMENT
Manjaro

MX Linux

ADVERTISEMENT

www.google.com

Google Chrome Browser - Use Chrome for


Faster Browsing - Google Chrome Keeps You
S f

Are Ubuntu and Linux Differ?


YES.

The primary difference between window and Linux is that window is open source and free OS and its
Linux distribution based on Debian, Whereas Linux is a large collection of open-source OSes that are
working based on Linux kernel.

Besides, Ubuntu is a distribution of Linux and Linux is a core system. Ubuntu is integrated by
Canonical Ltd. and published in 2004 and Linux is integrated by Linus Torvalds and published in 1991.
User mode vs Kernel mode
ADVERTISEMENT

The code of kernel component runs in a unique privilege mood known as kernel mode along with
complete access to every computer resource. This code illustrates an individual process, runs in an
individual address space, and don't need the context switch. Hence, it is very fast and efficient.

Kernel executes all the processes and facilitates various services of a system to the processes. Also, it
facilitates secured access to processes to hardware.

The support code that is not needed to execute in kernel mode is inside the system library. The user
programs and other types of system programs are implemented in the user mode.

ADVERTISEMENT ADVERTISEMENT

It includes no access to kernel mode and system hardware. User utilities/programs use the system
libraries for accessing kernel functions to obtain low-level tasks of the system.

← Prev Next →
ADVERTISEMENT
___
The Official Browser of Google - Google Works Better
on Chrome - One Click Away with Autofill
Now more simple, secure, and faster than ever - with Google's
smarts built in.. Be more productive with Google Chrome.
SPONSORED BY WWW.GOOGLE.COM Learn More

Linux Distributions (Distros)


Introduction to Linux Distribution
Other operating systems like Microsoft combine each bit of codes internally and release it as a single
package. You have to choose from one of the version they offer.

But Linux is different from them. Different parts of Linux are developed by different organizations.

Different parts include kernel, shell utilities, X server, system environment, graphical programs, etc. If
you want you can access the codes of all these parts and assemble them yourself. But its not an easy
task seeking a lot of time and all the parts has to be assembled correctly in order to work properly.

From here on distribution (also called as distros) comes into the picture. They assemble all these parts
for us and give us a compiled operating system of Linux to install and use.

ADVERTISEMENT
ADVERTISEMENT

A Linux distribution is an OS made through a software collection that contains the Linux kernel
and a package management system often.

Usually, Linux users obtain their OS by downloading a Linux distribution, available for a range
of systems from embedded devices (e.g., OpenWrt) to robust supercomputers (e.g., Rocks
Cluster Distribution).

A Linux distribution is composed of a Linux kernel, GNU libraries and tools, other software, a
window system, documentation, a desktop environment, and a window manager.

Almost every added software is open-source and free and becomes available both as in source
code and compiled binary form, permitting changes to the actual software.

Optionally, Linux distributions add a few proprietary software that might not be available in the
source code form, like binary blocks needed for a few device drivers.

History of Linux Distributions


Linus Torvalds integrated the Linux kernel and shared its first version, 0.01, in 1991. Initially, Linux was
distributed as only source code, and after that, as a combination of downloadable floppy disk images.
Distributions started simplifying the installation procedure as it was complicated, specifically during
the growing numbers of available software.

Users admired Linux distributions as replacements to the Microsoft Windows and DOS OSes on
proprietary Unix versions, Apple Macintosh Mac OS, and IBM PC compatible systems. Almost every
early adopter was familiar with Unix from school or work. They accepted Linux distributions for low
cost and the source code availability for all or most of their software.

Linux has become more famous in embedded and server device markets as compared to the desktop
market as of 2017. It is utilized on over 50% of web servers.

Trends and types


Linux distributions might be:

Non-commercial or commercial
Developed for home users, power users, or enterprise users
ADVERTISEMENT
Supported on two or more types of platform or hardware-specific, even to the certification
extension via platform vendor

Developed for embedded, desktop, or server devices

Highly specialized or general purpose toward particular machine functionalities (e.g., computer
clusters, network routers, and firewalls)

Targeted at particular user groups, e.g., by language internationalization and localization or by


including several scientific computing and music production packages

Primarily, built for comprehensiveness, portability, usability, or security


Rolling release or standard release

The Linux distribution diversity is because of the technical, philosophical, and organizational variation
among users and vendors. Free software licensing defines that users having sufficient interest and
knowledge can customize the existing distributions or create one to match their needs.

Linux Distributions List


There are on an average six hundred Linux distributors providing different features. Here, we'll
discuss about some of the popular Linux distros today.

1) Ubuntu

It came into existence in 2004 by Canonical and quickly became popular. Canonical wants Ubuntu to
be used as easy graphical Linux desktop without the use of command line. It is the most well known
Linux distribution. Ubuntu is a next version of Debian and easy to use for newbies. It comes with a
lots of pre-installed apps and easy to use repositories libraries.

Earlier, Ubuntu uses GNOME2 desktop environment but now it has developed its own unity desktop
environment. It releases every six months and currently working to expand to run on tablets and
smartphones.
2) Linux Mint
ADVERTISEMENT

Mint is based on Ubuntu and uses its repository software so some packages are common in both.

Earlier it was an alternative of Ubuntu because media codecs and proprietary software are included in
mint but was absent in Ubuntu. But now it has its own popularity and it uses cinnamon and mate
desktop instead of Ubuntu's unity desktop environment.

3) Debian

Debian has its existence since 1993 and releases its versions much slowly then Ubuntu and mint.

This makes it one of the most stable Linux distributor.

Ubuntu is based on Debian and was founded to improve the core bits of Debian more quickly and
make it more user friendly. Every release name of Debian is based on the name of the movie Toy
Story.
ADVERTISEMENT ADVERTISEMENT

4) Red Hat Enterprise / CentOS

Red hat is a commercial Linux distributor. There products are red hat enterprise Linux (RHEL) and
Fedora which are freely available. RHEL is well tested before release and supported till seven years
after the release, whereas, fedora provides faster update and without any support.

Red hat uses trademark law to prevent their software from being redistributed. CentOS is a
community project that uses red hat enterprise Linux code but removes all its trademark and make it
freely available. In other words, it is a free version of RHEL and provide a stable platform for a long
time.
5) Fedora
ADVERTISEMENT
It is a project that mainly focuses on free software and provides latest version of software. It doesn't
make its own desktop environment but used 'upstream' software. By default it has GNOME3 desktop
environment. It is less stable but provides the latest stuff.

Choosing a Linux Distro

Distribution Why To Use

UBuntu It works like Mac OS and easy to use.

Linux mint It works like windows and should be use by new comers.

Debian It provides stability but not recommended to a new user.

Fedora If you want to use red hat and latest software.

Red hat To be used commercially.


enterprise

CentOS If you want to use red hat but without its trademark.

OpenSUSE It works same as Fedora but slightly older and more stable.

Arch Linux It is not for the beginners because every package has to be installed by
yourself.
Examples of Linux Distributions
ADVERTISEMENT

Widely used GNU-compatible or GNU-based distributions

A non-commercial, Debian distribution and one of the primitives, managed by a volunteer developer
association with a commitment to democratic project management and free software principles.

Some other distributions are also available, such as Ubuntu, Linux Mint, Fedora Linux, Red Hat
Enterprise Linux, openSUSE, SUSE Linux Enterprise, Arch Linux, Manjaro Linux, Gentoo, etc.

ADVERTISEMENT ADVERTISEMENT

Linux kernel-based OSes

Android, the commercial operating system of Google, works on the basis of Android OSP that
executes on various devices like set-top boxes, smart TVs, smartphones, etc.

ChromeOS, the commercial operating system of Google, works on the basis of ChromiumOS,
which executes only on tablet computers, Chromeboxes, and Chromebooks. Like Android,
ChromeOS contains the Google Play Store and many Google apps.

Note: However, it is a questionable topic that the above OSes are considered as the "Linux
Distribution". They utilize the Linux kernel; hence, Chris DiBona (open-source chief of Google) and
the Linux Foundation admit that Android is also a Linux distribution.

Lightweight distributions

These distributions have been developed with support for earlier hardware, permitting earlier
hardware to be used productively or for the best possible speed in modern hardware by giving more
resources for use via applications. Some examples include Slitaz, Puppy Linux, and Tiny Core Linux.

Niche distributions

Some other distributions require specific niches, including:


Routers: e.g., targeted by OpenWrt (the Tiny embedded router distribution)
ADVERTISEMENT
Internet of things: e.g., targeted by Microsoft's Azure Sphere and Ubuntu Core

Home theatre PCs: e.g., targeted by Mythbuntu, Kodi (formerly XBMC), and KnoppMyth

Specific platforms: e.g., the Raspberry Pi platform is targeted by Raspberry Pi OS

Education: some examples are Karoshi and Edubuntu, and server systems are PCLinuxOS-
based

Scientific workstations and computer servers: e.g., aimed by Scientific Linux

Penetration testing, digital forensics, and computer security: some examples are Parrot
Security OS and Kali Linux

Anonymity and privacy: e.g., targeted by FreedomBox, Qubes, Whonix, or Tails

Gaming: e.g., SteamOS

Offline use: e.g., Endless OS

← Prev Next →

Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

Send your Feedback to [email protected]


ADVERTISEMENT

Google Chrome Browser - D


Ch O Cli k A

Linux Bash
The Linux Bash is also known as 'Bourne-again Shell.' It is a command language interpreter
for the Linux based system. It is a replacement of Bourne shell (sh). It was developed under the
GNU Project and written by Brian Fox. Nowadays, Bash is the default user shell of most of the
Linux distributions.

The Linux/Unix shell allows us to interact with the Linux system through the commands. It let us
invoke an executable file to create a running process. Moreover, it also allows us to interact
with the Linux file system. It is designed in such a way that we can perform all the Linux
operations through Bash.

The Bash is a command language interpreter as well as a programming language. It


supports variables, functions, and flow control, like other programming languages. It can
also read and execute the commands from a file, which is called a shell script.

It offers various functional improvements over Bourne Shell (sh) for both interactive and
programming use. Although many sh scripts can be run by Bash without any change. The Bash
contains the following improvements over sh:

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT ADVERTISEMENT

It provides command-line editing

It contains unlimited size command history

It provides Job Control

It facilitates with Shell Functions and Aliases

It provides the indexed arrays of unlimited size

It contains integer arithmetic in any base from 2 to 64.

How to download Bash

It can be downloaded from the official GNU server via both HTTP
(http://ftp.gnu.org/gnu/bash/) and FTP (ftp://ftp.gnu.org/gnu/bash/ ) servers.

People often get confused between bash, shell, and shell script. Let's walk through shell and
scripting to clear a picture of bash, shell, and scripting.

What is Shell
If we are a new Linux user, and we open the terminal, it is assumed that we are well confused as
to what to do with it. Here the Shell comes in the role.

The terminal contains the shell; it allows us to execute the commands to interact with the
system. We can perform various operations such as store and retrieve data, process
information, and various other simple as well as complex tasks.

To open the terminal, press CTRL+ALT+T keys. Perform some basic operations such as date,
cal, ls, and pwd to take a tour with it.
ADVERTISEMENT

ADVERTISEMENT

Consider the below image:

As we can see from the above image, the shell allows us to interact with the Linux system.
When we have executed the date and cal command, the shell interacts with the system and
retrieves data.

What is Scripting
Suppose we are required to execute some basic commands every day, for example above four
commands. Linux supports a feature called scripting that allows us to execute more than one
task at once. So, it is good to define a script rather than performing repetitive tasks.

To understand how to use Linux script, let's define a script in a combination of some tasks. To
define a script, create a file with a .sh extension. We are using the VI text editor. However, any
text editor can be used to define a script. Consider below command:
vi tasks.sh ADVERTISEMENT

The above command will open the vi editor in normal mode. Switch it to insert mode by
pressing ESC, and after that enter 'i' keys, enter your desired tasks. Every task should be
defined in a new line. Consider the below tasks:

date
cal
pwd
ls

After entering the tasks, press ESC and :wq! Keys to save and exit from the editor.

Now, make the created file as executable, use the chmod command with +x option as follows:
ADVERTISEMENT

chmod +x tasks.sh

We have created our first script. To execute the shell script, execute the file name by
predefining './ ' with the file name. Consider the below command:

./task.sh
Consider the below output:
ADVERTISEMENT

As we can see from the above output, by using the shell, we can automate the tasks. We can
use this whenever we need it. It can be used repeatedly any number of times.

Features of Bash
All the built-in command of the sh shell is available in Bash; moreover, it facilitates us with
many other features. Some key features of Bash are as follows:

Shell Syntax: The shell syntax contains shell operations, quoting, and comments. The
shell operations are the basic operation of the shell. Quoting allows how to remove the
special meaning from characters, and comments are meant to specify the comments.

Shell commands: Shell commands are the types of commands that you can execute.
These commands can be simple commands, pipelines, lists, compound commands, and
more.
Shell Functions: Shell functions are used to group commands by name. They are
executed as traditionalADVERTISEMENT
commands. When we use the name of a shell function, the list of
commands associated with that is executed.

Shell parameters: Basically, a parameter is an entity that stores value; it can be a name,
number, or special character. The shell parameters specify how the shell store value. They
can be a positional parameter or a special parameter. Positional parameters are the
shell's command-line arguments, and the special parameters are denoted by a special
character.

Shell Expansions: Shell expansion is a technique that is used by Bash to expand the
parameters. Expansion is performed on the command line after the input has been
splitted into tokens.

Redirections: It is a way to manage and control the input and output.

Command execution: It decides how the system will react when we execute a
command.

Shell Scripts: It is a text file that has shell commands and executes them when it is used.
Bash reads and executes the commands then exits.

← Prev Next →

ADVERTISEMENT

www.google.com

The Official Browser of Google - Use Chrome


for Faster Browsing - Chrome: A Faster Way
T B

Youtube For Videos Join Our Youtube Channel: Join Now


Linux Directory Structure
Prerequisite: Linux File Hierarchy Structure

In Linux/Unix operating system everything is a file even directories are


files, files are files, and devices like mouse, keyboard, printer, etc are
also files. Here we are going to see the Directory Structure in Linux.

Types of files in the Linux system.


1. General Files – It is also called ordinary files. It may be an image,
video, program, or simple text file. These types of files can be in
ASCII or Binary format. It is the most commonly used file in the
Linux system.
2. Directory Files – These types of files are a warehouse for other file
types. It may be a directory file within a directory (subdirectory).
3. Device Files – In a Windows-like operating system, devices like
CD-ROM, and hard drives are represented as drive letters like F: G:
H whereas in the Linux system devices are represented as files. As
for example, /dev/sda1, /dev/sda2, and so on.

We know that in a Windows-like operating system, files are stored in


different folders on different data drives like C: D: E: whereas in the
Linux/Unix operating system files are stored in a tree-like structure
starting with the root directory as shown in the below diagram.

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Got It !
data storage in Linux/Unix operating systems

The Linux/Unix file system hierarchy base begins at the root and
everything starts with the root directory.

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
These are the that
acknowledge common top-level
you have read directories
and understood our Cookieassociated
Policy & Privacywith
Policy the
root directory:
Directories Description
Shell Scripting Kali Linux Ubuntu Red Hat CentOS Docker in Linux Kubernetes in Linux Lin
/bin binary or executable programs.

/etc system configuration files.

/home home directory. It is the default current directory.

/opt optional or third-party software.

/tmp temporary space, typically cleared on reboot.

/usr User related programs.

/var log files.

Some other directories in the Linux system:

Directories Description

/boot It contains all the boot-related information files and


folders such as conf, grub, etc.

/dev It is the location of the device files such as dev/sda1,


dev/sda2, etc.

/lib It contains kernel modules and a shared library.

/lost+found It is used to find recovered bits of corrupted files.

/media It contains subdirectories where removal media devices

We use cookies to ensureare inserted.


you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Directories Description

/mnt It contains temporary mount directories for mounting the


file system.

/proc It is a virtual and pseudo-file system to contains info


about the running processes with a specific process ID or
PID.

/run It stores volatile runtime data.

/sbin binary executable programs for an administrator.

/srv It contains server-specific and server-related files.

/sys It is a virtual file system for modern Linux distributions to


store and allows modification of the devices connected to
the system.

Exploring directories and their usability:

We know that Linux is a very complex system that requires an efficient


way to start, stop, maintain and reboot a system, unlike Windows
operating system. In the Linux system some well-defined
configuration files, binaries, main pages information files are available
for every process.

Linux Kernel File:


/boot/vmlinux – The Linux kernel file.

Device Files:
/dev/hda – Device file for the first IDE HDD.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
/dev/hdc – Athat
acknowledge pseudo-device that output
you have read and understood garbage
our Cookie Policy &output is
Privacy Policy
redirected to /dev/null.
System Configuration Files:

Configuration Description
Files

/etc/bashrc It is used by bash shell that contains system


defaults and aliases.

/etc/crontab A shell script to run specified commands on a


predefined time interval.

/etc/exports It contains information on the file system


available on the network.

/etc/fstab Information of the Disk Drive and their mount


point.

/etc/group It is a text file to define Information of Security


Group.

/etc/grub.conf It is the grub bootloader configuration file.

/etc/init.d Service startup Script.

/etc/lilo.conf It contains lilo bootloader configuration file.

/etc/hosts Information of IP and corresponding hostnames

/etc/hosts.allow It contains a list of hosts allowed accessing


services on the local machine.

/etc/host.deny List of hosts denied accessing services on the


local machine.

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
/etc/inittab INITand
acknowledge that you have read process andour
understood their interaction
Cookie at the
Policy & Privacy various
Policy
run levels.
Configuration Description
Files

/etc/issue Allows editing the pre-login message.

/etc/modules.conf It contains the configuration files for the system


modules.

/etc/motd It contains the message of the day.

/etc/mtab Currently mounted blocks information.

/etc/passwd It contains username, password of the system,


users in a shadow file.

/etc/printcap It contains printer Information.

/etc/profile Bash shell defaults.

/etc/profile.d It contains other scripts like application scripts,


executed after login.

/etc/rc.d It avoids script duplication.

/etc/rc.d/init.d Run Level Initialisation Script.

/etc/resolv.conf DNS being used by System.

/etc/security It contains the name of terminals where root login


is possible.

/etc/skel Script that initiates new user home directory.

/etc/termcap An ASCII file that defines the behavior of different


We use cookies to ensure you have the best browsing experience on our website. By using our site, you
types
acknowledge that you have read and understood ourof the Policy
Cookie terminal.
& Privacy Policy
Configuration Description
Files

/etc/X11 Directory tree contains all the conf files for the X-
window System.

User Related Files:

User Related Descriptions


Files

/usr/bin It contains most of the executable files.

/usr/bin/X11 Symbolic link of /usr/bin.

/usr/include It contains standard files used by C program.

/usr/share It contains architecture independent shareable text


files.

/usr/lib It contains object files and libraries.

/usr/sbin It contains commands for Super User, for System


Administration.

Virtual and Pseudo Process Related Files:

Virtual and Pseudo Descriptions


Process Related Files

/proc/cpuinfo CPU Information

/proc/filesystems It keeps useful info about the processes


We use cookies to ensure you have the best browsing experience on our
that are website. By
currently using our site, you
running.
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Virtual and Pseudo Descriptions
Process Related Files

/proc/interrupts it keeps the information about the


number of interrupts per IRQ.

/proc/ioports Contains all the Input and Output


addresses used by devices on the
server

/proc/meminfo It reports the memory usage


information.

/proc/modules Currently using kernel module.

/proc/mount Mounted File-system Information.

/proc/stat It displays the detailed statistics of the


current system.

/proc/swaps It contains swap file information.

Version Information File:


/version – It displays the Linux version information.

Log Files:

Log Files Descriptions

/var/log/lastlog It stores user’s last login info.

/var/log/messages It has all the global system messages

/var/log/wtmp It keeps a history of login and logout information.


We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy
To check the Linux directories, open the terminal and execute sudo -s
followed by system password to give root privilege. Then after
changing the current home directory to the root directory and check
the list of all available directories in the base directory as shown
below.

Linux directories

Conclusion
If we understand the Linux directory’s structure correctly, it would be
so easy to effectively navigate and manage our filesystem, locate
important configuration files, and access system information. One
must know that the directory structure and specific file mentioned in
this article are based on standard Linux conventions. We must
consider that the different Linux distributions may have variations in
the directory structure and specific file locations, but overall concept
and organization remain similar.

Here's a complete roadmap for you to become a developer: Learn DSA


-> Master Frontend/Backend/Full Stack -> Build Projects -> Keep
Applying to Jobs And why go anywhere else when our DSA to
Development: Coding Guide helps you do this in a single program!
Apply now to our DSA to Development Program and our counsellors
will connect with you for further guidance & support.

Last Updated : 08 Jun, 2023 23

We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our Cookie Policy & Privacy Policy Next
Previous

You might also like