Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Linux and Shell Programming

The document provides a comprehensive overview of Linux and shell programming, covering topics such as the Linux operating system, its features, and various shell commands. It discusses the history of Linux, the differences between compilers and interpreters, process management, and debugging techniques. Additionally, it includes practical information on using the vi editor, file handling, and basic commands in Linux.

Uploaded by

mpari0181
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Linux and Shell Programming

The document provides a comprehensive overview of Linux and shell programming, covering topics such as the Linux operating system, its features, and various shell commands. It discusses the history of Linux, the differences between compilers and interpreters, process management, and debugging techniques. Additionally, it includes practical information on using the vi editor, file handling, and basic commands in Linux.

Uploaded by

mpari0181
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

LINUX AND SHELL PROGRAMMING

BY
R.GOVARTHINI
CONTENT
• INTRODUCTION TO LINUX
• OPERATING SYSTEM IN LINUX
• LINUX DISTRIBUTIONS
• VI EDITORS
• LINUX OVERVIEW
• FEATURES OF LINUX
• COMPARISON OF SHELL
• DIFFERENCE BETWEEN COMPILER AND INTERPRETER
• PROCESS
• LOGICAL OPERATORS
• INTERACTIVE SHELL SCRIPTING
• SHIFT OPERATOR
• WC COMMAND
• FILE HANDLING
• DEBUGGING
• AUTOMATING DECISION
INTRODUCTION TO LINUX

The Linux Operating System is a type of


operating system that is similar to Unix, and it
is built upon the Linux Kernel. The Linux
Kernel is like the brain of the operating
system because it manages how the computer
interacts with its hardware and resources. It
makes sure everything works smoothly and
efficiently. But the Linux Kernel alone is not
enough to make a complete operating system.
To create a full and functional system, the
Linux Kernel is combined with a collection of
software packages and utilities, which are
together called Linux distributions.
OPERATING SYSTEM AND LINUX
• Developed by Linus Torvalds in 1991,
the Linux operating system is a
powerful and flexible open-source
software platform. It acts as the basis
for a variety of devices, such
embedded systems, cell phones,
servers, and personal computers.
Linux, that’s well-known for its
reliability, safety, and flexibility, allows
users to customize and improve their
environment
FEATURES OF LINUX
• Free and Open Source

• Multiuser Capacity

• Multitasking

• Security

• Graphical User Interface (GUI)

• File System

• Application Support

VI EDITOR

The default editor that comes with the


Linux/UNIX operating system is called
vi (visual editor). Using vi editor, we can
edit an existing file or create a new file
from scratch. we can also use this
editor to just read a text file. The
advanced version of the vi editor is the
vim editor.
HISTORY OF LINUX
• In 1991, while studying computer science at University of Helsinki,
Linus Torvalds began a project that later became the Linux kernel.
He wrote the program specifically for the hardware he was using
and independent of an operating system because he wanted to
use the functions of his new PC with an 80386 processor.
Development was done on MINIX using the GNU C Compiler.

• On July 3, 1991, in an effort to implement Unix system calls in his


project, Linus Torvalds attempted to obtain a digital copy of the
POSIX standards documentation with a request to the comp.os .
LINUX OVERVIEW
• Linux is an open source operating system (OS). It was designed to be similar
to UNIX. The operating system connects the software and hardware parts of
the system. Linux has evolved to run on a variety of hardware like
supercomputers, smartphones, cars, enterprise servers, home appliances,
and home desktops.

• In several ways, it is similar to other operating systems like Mac, Windows,


iOS. It has a graphical interface, and if one can use electronic devices and
computers, one can easily use Linux. It has the same types of software like
photo editors, word processors, video editors, and so on. However, it is open-
source software, which means the codes are free and available for everyone.
COMPARISON OF SHELL
• Unix OS used a shell program called the Bourne shell.
Then, eventually, many more shell programs were
developed for different flavors of Unix. The following is
some brief information about different shells:
• csh—C shell
• ksh—Korn shell
• tcsh—enhanced C shell
• bash—GNU Bourne Again shell
• zsh—extension to bash, ksh, and tcsh
PROCESS
• Process management is a basic idea in operating
systems, particularly in Linux contexts. It serves as the
framework for seamless multitasking, effective resource
management, and general system stability.
Types of process,they are
orphan process
zombie process
deamon process
ORPHAN PROCESS

• A process whose parent process no more exists i.e. either


finished or terminated without waiting for its child process
to terminate is called an orphan process. In the following
code, parent finishes execution and exits while the child
process is still executing and is called an orphan process
ZOMBIE PROCESS
• A Zombie is a process that has completed its task but
still, it shows an entry in a process table. The zombie
process usually occurred in the child process. Very short
time the process is a zombie. After the process has
completed all of its tasks it reports the parent process that
it has about to terminate.
DAEMON PROCESS
• Daemon processes are started working when the system
will be bootstrapped and terminate only when the system
is shutdown .It does not have a controlling terminal. It
always runs in the background.
COMPILER AND INTERPRETER
BASIC OPERATOR IN SHELL SCRIPTING
• Arithmetic Operators: These operators are used to
perform normal arithmetics/mathematical operations.
There are 7 arithmetic operators:

• Addition (+): Binary operation used to add two operands.


• Subtraction (-): Binary operation used to subtract two
operands.
• Multiplication (*): Binary operation used to multiply two
operands.
• Division (/): Binary operation used to divide two operands.
RELATIONAL OPERATOR
• Relational Operators: Relational operators are those
operators which define the relation between two
operands. They give either true or false depending upon
the relation. They are of 6 types:

• ‘==’ Operator: Double equal to operator compares the two


operands. Its returns true is they are equal otherwise
returns false.
• ‘!=’ Operator: Not Equal to operator return true if the two
operands are not equal otherwise it returns false.
BITWISE OPERATOR
• Bitwise Operators: A bitwise operator is an operator used
to perform bitwise operations on bit patterns. They are of
6 types:

• Bitwise And (&): Bitwise & operator performs binary AND


operation bit by bit on the operands.
FILE TEST OPERATOR
• File Test Operator: These operators are used to test a
particular property of a file.

• -b operator: This operator check whether a file is a block


special file or not. It returns true if the file is a block
special file otherwise false.
• -c operator: This operator checks whether a file is a
character special file or not. It returns true if it is a
character special file otherwise false.
• -d operator: This operator checks if the given directory
exists or not.
FILE OPERATOR
• -r operator: This operator checks whether the given file
has read access or not. If it has read access then it
returns true otherwise false.
• -w operator: This operator check whether the given file
has write access or not. If it has write then it returns true
otherwise false.
• -x operator: This operator check whether the given file
has execute access or not. If it has execute access then it
returns true otherwise false.
• -s operator: This operator checks the size of the given file.
If the size of given file is greater than 0 then it returns
ARRAY BASIC IN SHELL SCRIPTING
• An array is a structured arrangement of similar data
elements. Within shell scripting, an array is a variable that
holds multiple values, whether they are of the same type
or different types. It’s important to note that in shell
scripting, everything is treated as a string. Arrays adhere
to a zero-based index, which signifies that indexing
initiates from 0.
ARRAYS IN SHELL SCRIPT
• Arrays can be declared in a shell script using various
approaches:

• 1. Indirect Declaration
• In this method, you assign a value to a specific index of
the array variable. There’s no need to declare the array
beforehand.

• ARRAYNAME[INDEXNR]=value
ARRAYS IN SHELL SCRIPT
• 2.Explicit Declaration
• With explicit declaration, you first declare the array and
then assign values to it.

• declare -a ARRAYNAME
• 3. Compound Assignment
• This method involves declaring the array along with its
initial set of values. You can later add additional values to
the array.
LOGICAL OPERATOR
• logical operators are used to test multiple conditions and
determine the outcome of the script based on those
conditions. Logical operators can be used to create
complex conditional statements that allow for more
dynamic and flexible scripts. These operators include
AND, and OR
WC COMMAND
• wc stands for word count. As the name implies, it is
mainly used for counting purpose. It is used to find out
number of lines, word count, byte and characters count in
the files specified in the file arguments. By default it
displays four-columnar output
BASIC COMMANDS IN LINUX
• Linux Directory Commands
• 1. pwd Command

• The pwd command is used to display the location of the


current working directory.

• Syntax:

• pwd
BASIC COMMANDS
• The Linux command is a utility of the Linux operating
system. All basic and advanced tasks can be done by
executing commands. The commands are executed on
the Linux terminal. The terminal is a command-line
interface to interact with the system, which is similar to
the command prompt in the Windows OS. Commands in
Linux are case-sensitive.
SET COMMAND
• Linux set command is used to set and unset certain flags
or settings within the shell environment. These flags and
settings determine the behavior of a defined script and
help in executing the tasks without facing any issue. The
values of shell attributes and parameters can be changed
or displayed by using the set command.
GREP COMMAND
• The 'grep' command stands for "global regular expression
print". grep command filters the content of a file which
makes our search easy.

• It is a command-line utility to search plain-text data


groups for lines that are the same as a regular
expression. The name "grep" comes from the command,
i.e., ed, which contains the same effect. Originally, grep
was designed for the Unix operating system, but it
became available for every Unix-like system later and a
few others like OS 9.
BASIC COMMAND IN LINUX
• 2. mkdir Command

• The mkdir command is used to create a new directory


under any directory.

• Syntax:

• mkdir <directory name>


BASIC COMMANDS
• 6. touch Command

• The touch command is used to create empty files. We can


create multiple empty files by executing it once.

• Syntax:

• touch <file name>


• touch <file1> <file2> ....
UNDERSTANDING SET
• The set command in Linux is a built-in shell command that
allows users to customize their shell environment and
control shell options. It's a key component of shell
scripting and can be used for a variety of tasks, including:

• Displaying and modifying variables: The set command


can be used to display and change the names and values
of shell and environment variables.
DEBUGGING
• Debugging is a computer engineering process that
identifies, isolates and corrects or determines the best
way to work around a problem in applications.
• Debugging is the process of finding and resolving coding
errors or “bugs” in a software program.
DEBUGGING MODE
• To switch on shell tracing, use the -x debugging option.
This directs the shell to display all commands and their
arguments on the terminal as they are executed. We will
use the sys_info.sh shell script below, which briefly prints
your system date and time, number of users logged in
and the system uptime.
CONCLUSION
• A Linux-based system is a modular Unix-like operating
system, deriving much of its basic design from principles
established in Unix during the 1970s and 1980s. Such a
system uses a monolithic kernel, the Linux kernel, which
handles process control, networking, access to the
peripherals, and file systems.
THANK YOU
BY
R.GOVARTHINI

You might also like