0% found this document useful (0 votes)
55 views29 pages

Linux Shell and Shell Scripting TCS 492 2024

The document discusses the differences between monolithic and microkernel operating system designs. Monolithic kernels have all services integrated in the kernel space, whereas microkernels have most services running in user space. Monolithic kernels generally have better performance due to less data movement between kernel and user space, while microkernels are more modular and secure as bugs in services don't affect the whole system. Developing monolithic kernels is simpler than microkernels.

Uploaded by

blackdevil1047
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
55 views29 pages

Linux Shell and Shell Scripting TCS 492 2024

The document discusses the differences between monolithic and microkernel operating system designs. Monolithic kernels have all services integrated in the kernel space, whereas microkernels have most services running in user space. Monolithic kernels generally have better performance due to less data movement between kernel and user space, while microkernels are more modular and secure as bugs in services don't affect the whole system. Developing monolithic kernels is simpler than microkernels.

Uploaded by

blackdevil1047
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 29

Linux shell and Shell Scripting

System services: In a monolithic kernel, all system services run in kernel space,
whereas in a microkernel, only the most basic services (such as memory
management and process scheduling) run in kernel space, with other services
running in user space.
Performance: Monolithic kernels are generally faster and more efficient than
microkernels, because there is no overhead associated with moving data
between kernel space and user space.
Modularity: Microkernels are more modular than monolithic kernels, because
services are separated into different processes running in user space. This
makes it easier to add or remove services without affecting other parts of the
system.
Security: Microkernels are generally considered more secure than monolithic
kernels, because a bug or vulnerability in a service running in user space is less
likely to affect the entire system.
Development: Developing a monolithic kernel is generally simpler and faster
than developing a microkernel, because all system services are integrated and
share the same memory space.
Linux Shell Terminologies
• If you are using any major operating system you
are indirectly interacting to shell.
• Three Important terminologies –
–Kernel
–Shell
–Terminal
Linux Kernel
• The Linux kernel has found its way into an incredible
number of diverse systems. It can now be found in
everything from automobiles to rockets, watches to
televisions, and netbooks to the fastest
supercomputers.
• Linux only accounts for a relatively small percentage of
the operating systems found on desktop computers,
but has gained widespread use in servers, Internet of
Things (IoT) devices, networking equipment,
smartphones, and many other devices you may not
think of as even being computers.
• From the home router providing your Internet
connection to the server this course is hosted on, it is
likely that multiple Linux powered devices are currently
enabling you to read this page.
What is Kernel
• The kernel is a computer program that is the
core of a computer’s operating system, with
complete control over everything in the
system.
• It manages following resources of the Linux
system –
– File management
– Process management
– I/O management
– Memory management
– Device management etc.
Complete Linux system = Kernel
+ GNU system utilities and
libraries + other management
scripts + installation scripts.
GNU stands for “GNU's Not Unix”
What is Shell
• A shell is special user program which provide
an interface to user to use operating system
services.
• Shell accept human readable commands from
user and convert them into something which
kernel can understand.
• It is a command language interpreter that
execute commands read from input devices
such as keyboards or from files.
• The shell gets started when the user logs in or
start the terminal.
Types of Shell
• Shell is broadly classified into two categories –
–Command Line Shell
–Graphical shell
Types of Shell
There are several shells are available for Linux
systems like
• BASH (Bourne Again SHell) – It is most widely used
shell in Linux systems. It is used as default login
shell in Linux systems and in macOS. It can also be
installed on Windows OS.
• CSH (C SHell) – The C shell’s syntax and usage are
very similar to the C programming language.
• KSH (Korn SHell) – The Korn Shell also was the base
for the POSIX Shell standard specifications etc.
Each shell does the same job but understand
different commands and provide different built in
functions.
To check which is your current shell
Shell Scripting
• Usually shells are interactive that mean, they
accept command as input from users and execute
them. However some time we want to execute a
bunch of commands routinely, so that we need
not have to type all commands each time in
terminal.

• As shell can also take commands as input from


file we can write these commands in a file and
can execute them in shell to avoid this repetitive
work. These files are called Shell Scripts(or shell
Programs) or Shell programs
Shell Scripting
• Each shell script is saved with .sh file
extension eg. myscript.sh
• A shell script have syntax just like any other
programming language. If you have any prior
experience with any programming language
like Python, C/C++ etc. it would be very easy
to get started with it.
Shell scripting examples
Shell Scripting
• A shell script comprises following elements –
– Shell Keywords – if, else, break etc.
– Shell commands – cd, ls, echo, pwd, touch etc.
– Functions
– Control flow – if..then..else, case and shell loops
etc.
Why do we need shell scripts

• There are many reasons to write shell scripts –


– To avoid repetitive work and automation
– System admins use shell scripting for routine
backups
– System monitoring
– Adding new functionality to the shell etc.
Advantages of shell scripts
• The command and syntax are exactly the same
as those directly entered in command line, so
programmer do not need to switch to entirely
different syntax
• Writing shell scripts are much quicker
• Quick start
• Interactive debugging etc.
Shell Script Example 1
Shell Script Example 2

You might also like