SlideShare a Scribd company logo
1 of 51
Download to read offline
Dr. D. P.
Mishra
Digitally signed by Dr. D. P. Mishra
DN: cn=Dr. D. P. Mishra, o=durg,
ou=BIT, email=dpmishra@bitdurg.
ac.in, c=IN
Date: 2023.02.14 13:34:20 +05'30'
grep command
• grep stands for global search for regular expression and print.
• The grep filter searches a file for a particular pattern of characters, and
displays all lines that contain that pattern
• searched pattern in the file is referred as the regular expression
• Syntax :
• grep [options] pattern [files]
• Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Example
$cat > geekfile.txt
unix is great os. unix was developed in Bell labs.
learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
$grep -i "UNix" geekfile.txt
Output:
unix is great os. unix was developed in Bell labs.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
egrep
• The egrep (Extended Global Regular Expression Print) command
• It is text processing tool that searches for patterns or regular
expressions in a specified location.
• The tool provides the same output as grep in faster mode
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
fgrep
• The fgrep command displays the file that contains the matched line if
you specify more than one file in the File parameter.
• The fgrep command differs from the grep and egrep commands
because it searches for a string instead of searching for a pattern
• fgrep is equivalent to grep -F command and it uses a fixed string for
search and hence it performs a faster search
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ fgrep [OPTIONS] PATTERNS [FILES] $ cat input.txt
cut command
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• Linux cut command is useful for selecting a specific column of a file.
• It is used to cut a specific sections by byte position, character, and field
and writes them to standard output.
• It cuts a line and extracts the text data
• Syntax :
• $ cut OPTION... [FILE]...
Example
• $ cat > state.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
Apply following commands on state.txt:
List Without ranges: $ cut -b 1,2,3 state.txt
List with ranges : $ cut -b 1-3,5-7 state.txt
$ cut -b 1- state.txt
$ cut -b -3 state.txt
$ cut -c 2,5,7 state.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Paste Command
• Paste command is used to join files horizontally (parallel merging) by
outputting lines consisting of lines from each file specified, separated
by tab as delimiter, to the standard output.
• When no file is specified, or put dash (“-“) instead of file name, paste
reads from standard input and gives output as it is until a interrupt
command [Ctrl-c] is given.
• Syntax: paste [OPTION]... [FILES]...
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ cat > capital
Itanagar
Dispur
Hyderabad
Patna
Raipur
$ paste number state capital
$ paste -d "|" number state capital
1|Arunachal Pradesh|Itanagar
2|Assam|Dispur
3|Andhra Pradesh|Hyderabad
4|Bihar|Patna
5|Chhattisgrah|Raipur
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Example
unmae & wget command
$ uname
• You can use the command to get the release number, version of Linux, and
much more.
• The “-a” flag is used to get detailed information.
$ wget
• You can use the wget command to download the content from the internet;
• for instance, the following command will download VirtualBox.
$ wget https://download.virtualbox.org/virtualbox/6.1.26/VirtualBox-6.1.26-
145957-Win.exe
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
apt-get or –apt command
• Most important and most used commands of Ubuntu that works with
Ubuntu Advanced Packaging Tool (APT);
• You can use this “-apt-get” or “-apt” to install or remove packages
• The “apt” requires sudo privileges to successfully execute the
command.
• Syntax : $ sudo apt install [packagename]
• To install vlc media player package use
• $ sudo apt install vlc
• To remove package - $ sudo apt remove [packagename]
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
history command
• The history command shows the
list of commands (with numeric
numbers) executed
• $ history
• One can execute any of the listed
commands
• If you want to execute the 2nd
command (which is apt update
command), then you have to write
“!74” to get the result of that
command:
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
ps command
• ps - using the -ps command, you will be able to get the list of
processes.
$ ps
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
w command
• W command will display the user details that are currently logged into
the system
• $ w
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
passwd
• passwd - With the help of the passwd command, you can change the
password of your Ubuntu user:
• You must pass “username” to “passwd” to change the password of
that; for example, the command given below will change the password
of user “6cse01”
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
hostname command
• This command will print your hostname on the terminal
• $ hostname
• bitlinux@6cse01 $ bitlinux
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
ping command
• Ping - you can use the ping command to check the connectivity to your server;
• for example, the command below will ping to YouTube and also prints the
response time
• $ping hostname or ip-address
• $ ping youtube.com
• $ ping google.com
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ uptime -shows how long system is running
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ users – shows username who are currently logged in
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ service – call and execute script
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ service --status-all
$ ps – display about running process
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
kill, killall and pkill
• kill terminates processes based on Process ID number (PID),
• While the killall and pkill commands terminate running processes
based on their names and other attributes.
• Example
$ ps
PID TTY TIME CMD
11571 pts/20 00:00:00 bash
22166 pts/20 00:00:00 ps
$ kill -s 0 11571
$ kill -s 0 11579
bash: kill: (11579) - No such process
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ pmap – memory map of process
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ free – shows memory status
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ netstat – display network status
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ nslookup – check domain name of ip info
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ route - list routing table for your server
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
ftp command
• Here, ftp stands for File Transfer Protocol. This utility helps you upload
and download your file from one computer to another computer.
• $ftp hostname or ip-address
• $ftp 172.16.0.100
• ftp> dir
• ftp> get <filename>
• ftp> quit
• 221 Goodbye.
• $
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
More Commands
• join
• Tee
• Comm
• Cmp
• Diff
• tr
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Text Editing with Vi Editor
(vi- Visual Editor)
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Vi Editor
• The VI editor is a screen based editor used by many unix users.
• It is the default editor that comes with the UNIX operating systems
and is called vi (visual editor).
• The improved version of vi is called the vim editor ( vi improved) is
available with Linux systems.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Modes of vi editor
• There are three basic modes of vi:-
1. Command mode
2. Insert mode
3. Line mode
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
1. Command mode:-
• This the default when you enter vi.
• In command mode - most letters, or short sequence of letters, that
you type will be interpreted as commands, without explicitly pressing
Enter.
• If you press ESC when you’re in command mode, your terminal will
beep at you.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
2. Insert Mode
• Insert mode:- In insert mode, whatever you type is inserted in the file
at the cursor position.
• Type i to enter insert mode from command mode;
• press ESC to end insert mode, and return to command mode.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
3. Line mode
• Line mode:- Use line mode to enter line oriented commands.
• To enter line mode from command mode, type a colon(:).
• Your cursor moves to the bottom of the screen, by a colon prompt.
• Type a line mode command and then press ENTER.
• Each time you use a line mode command, you must
• type a colon to enter line mode,
• then type the command by the colon prompt at the bottom of the screen,
• then press ENTER when you finish typing the command
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Starting and stopping vi
• To edit file
$ vi generalnote
• Above command starts vi and allocates a memory buffer for
file generalnote
• If the file already exists, text in the file will be displayed on the screen.
• You can't add any text to the file until you go into insert mode because
vi started in the command mode.
• The tilde character (~) you see in the screen shot shows that the file
has no text in these lines.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Starting and stopping vi
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• The tilde character (~) you see in the screen
shot shows that the file has no text in these
lines.
• To switch to insert mode, press the
i character
• Press the Esc & : key to return to command
mode.
• To save file use :w command.
• To quit the editor use :q command
• Use : x or wq to save and quit in one step
Cursor Movement Commands
• The mouse does not move the cursor
within the vi editor screen. You must
have the key commands listed.
• Before using any of these
commands, make sure that you are
in the command mode by pressing
the ESC & : key.
• You can also instruct the vi editor to
display the line number with each
line using the :set
number command.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Symbol Function
l Move one character right
h Move one character left
j Move one line down
k Move one line up
< space > Move one character right
G Go to last line of the file
nG Go to line number n in the file
$ Go to end of current line
^ Go to start of line
w Go to beginning of next word
b Go to beginning of previous word
e Move to end of word
H Go to first line of screen
M Go to middle line of screen
L Go to last line of screen
( Go to beginning of sentence
) Go to end of sentence
{ Go to beginning of paragraph
} Go to end of paragraph
Inserting text in vi
Command Effect
i Start inserting text at the current cursor location.
I Start inserting text at the beginning of the current line.
a Start inserting text at the next character position relative to the current cursor
location.
A Start inserting text at the end of the current line.
o Append a blank line just below the current line and start inserting text from the
beginning of that line.
O Append a blank line just above the current line and start inserting text from the
beginning of that line.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Deleting text in vi
Command Effect
x Delete character at current cursor location.
nx Delete n characters starting at current cursor location.
X Delete previous character from the current cursor location.
nX Delete n previous characters from the current cursor location.
dd Delete current line.
db Delete previous word.
dw Delete from current cursor location to the end of word.
dG Delete to the end of file including current line.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Text replacement command in vi
Command Effect
r Replace current character remaining in command mode
s Replace current character and go to insert mode
R Replace multiple characters until the key is pressed
cw Change to the beginning of next word
cc Change entire line
cG Change to the end of file
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Cut, Copy, and Paste Commands
Command Effect
yy Copy or yank current line
nyy Copy n lines starting from current line position
p Paste yanked text after the current cursor position
P Paste yanked text before the current cursor position
:m a Move current line and paste after line number a
:a,bmc Move lines from a to b and paste after line number c
:a,btc Copy lines from a to b and paste after line number c
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Shell Scripting /Programming
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
What is in a shell script?
• A shell script is a text file that contains a sequence of commands for a
UNIX-based operating system.
• Shell scripting is an important part of process automation in Linux.
• Scripting helps you write a sequence of commands in a file and then
execute them.
• This saves you time because you don't have to write certain
commands again and again
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
How to write shell script
• Following steps are required to write shell script:
• (1) Use any editor like vi or gedit to write shell script.
• (2) After writing shell script set execute permission
• (3) Execute shell script as
• syntax:
• bash shell-script-name
• sh shell-script-name
• ./your-script-name
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
First shell script
echo "Our first script"
echo "--------------------------------------------"
echo # This inserts an empty line in output.
echo "We are currently in the following directory"
pwd
echo "This directory contains the following files"
ls
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Prog1: Write following shell script, save it, execute it and
note down the it's output.
$ vi ginfo
#
#
# Script to print user information who currently login , current date & time
#
clear
echo "Hello $USER"
echo "Today is c ";date
echo "Number of user login : c" ; who | wc -l
echo "Calendar"
cal
exit 0
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Prog 2 : Using if-else to check whether two numbers are equal
a=10
b=20
if [ $a -eq $b ]
then
echo " Number is equal "
else
echo " number not equal "
fi
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
C- Program in Linux Environment
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
First C Program
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Steps:
• Write program in vi editor
• Save with .c extension
• Comiple :
$ gcc progname.c
• Run ;
$ ./a.out
Linux Commands

More Related Content

Similar to Linux Commands

Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationJacobMenke1
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Lineazzamhadeel89
 
Linux week 2
Linux week 2Linux week 2
Linux week 2Vinoth Sn
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filtersAcácio Oliveira
 
55 best linux tips, tricks and command lines
55 best linux tips, tricks and command lines55 best linux tips, tricks and command lines
55 best linux tips, tricks and command linesArif Wahyudi
 
How to admin
How to adminHow to admin
How to adminyalegko
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 

Similar to Linux Commands (20)

Chapter 1: Introduction to Command Line
Chapter 1: Introduction to  Command LineChapter 1: Introduction to  Command Line
Chapter 1: Introduction to Command Line
 
Linux
LinuxLinux
Linux
 
Group13
Group13Group13
Group13
 
Ultimate Unix Meetup Presentation
Ultimate Unix Meetup PresentationUltimate Unix Meetup Presentation
Ultimate Unix Meetup Presentation
 
Chapter 1: Introduction to Command Line
Chapter 1: Introduction  to Command LineChapter 1: Introduction  to Command Line
Chapter 1: Introduction to Command Line
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
55 best linux tips, tricks and command lines
55 best linux tips, tricks and command lines55 best linux tips, tricks and command lines
55 best linux tips, tricks and command lines
 
linux installation.pdf
linux installation.pdflinux installation.pdf
linux installation.pdf
 
How to admin
How to adminHow to admin
How to admin
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
linux OS.pptx
linux OS.pptxlinux OS.pptx
linux OS.pptx
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
linux cmds.pptx
linux cmds.pptxlinux cmds.pptx
linux cmds.pptx
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
Nithi
NithiNithi
Nithi
 

More from BIT DURG

JavaScript
JavaScriptJavaScript
JavaScriptBIT DURG
 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWWBIT DURG
 
Computer Networks
Computer NetworksComputer Networks
Computer NetworksBIT DURG
 
Computer Basics
Computer Basics Computer Basics
Computer Basics BIT DURG
 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATMBIT DURG
 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control ProtocolBIT DURG
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing ProtocolsBIT DURG
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdfBIT DURG
 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IPBIT DURG
 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network BasicsBIT DURG
 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells BIT DURG
 
File Access Permission
File Access PermissionFile Access Permission
File Access PermissionBIT DURG
 
Control flow and related shell cripts
Control flow and related shell criptsControl flow and related shell cripts
Control flow and related shell criptsBIT DURG
 
Basic Shell Programs
Basic Shell ProgramsBasic Shell Programs
Basic Shell ProgramsBIT DURG
 
Linux Installation
Linux InstallationLinux Installation
Linux InstallationBIT DURG
 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & LinuxBIT DURG
 
National youth day
National youth dayNational youth day
National youth dayBIT DURG
 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic TutorialsBIT DURG
 

More from BIT DURG (20)

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
 
Computer Networks
Computer NetworksComputer Networks
Computer Networks
 
Computer Basics
Computer Basics Computer Basics
Computer Basics
 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATM
 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control Protocol
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IP
 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network Basics
 
MySQL
MySQL MySQL
MySQL
 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
 
Control flow and related shell cripts
Control flow and related shell criptsControl flow and related shell cripts
Control flow and related shell cripts
 
Basic Shell Programs
Basic Shell ProgramsBasic Shell Programs
Basic Shell Programs
 
Linux Installation
Linux InstallationLinux Installation
Linux Installation
 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & Linux
 
National youth day
National youth dayNational youth day
National youth day
 
Visual Basic Tutorials
Visual Basic TutorialsVisual Basic Tutorials
Visual Basic Tutorials
 

Recently uploaded

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 

Recently uploaded (20)

UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 

Linux Commands

  • 1. Dr. D. P. Mishra Digitally signed by Dr. D. P. Mishra DN: cn=Dr. D. P. Mishra, o=durg, ou=BIT, email=dpmishra@bitdurg. ac.in, c=IN Date: 2023.02.14 13:34:20 +05'30'
  • 2. grep command • grep stands for global search for regular expression and print. • The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern • searched pattern in the file is referred as the regular expression • Syntax : • grep [options] pattern [files] • Options Description -c : This prints only a count of the lines that match a pattern -h : Display the matched lines, but do not display the filenames. -i : Ignores, case for matching -l : Displays list of a filenames only. -n : Display the matched lines and their line numbers. -v : This prints out all the lines that do not matches the pattern -e exp : Specifies expression with this option. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 3. Example $cat > geekfile.txt unix is great os. unix was developed in Bell labs. learn operating system. Unix linux which one you choose. uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful. $grep -i "UNix" geekfile.txt Output: unix is great os. unix was developed in Bell labs. Unix linux which one you choose. uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 4. egrep • The egrep (Extended Global Regular Expression Print) command • It is text processing tool that searches for patterns or regular expressions in a specified location. • The tool provides the same output as grep in faster mode Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 5. fgrep • The fgrep command displays the file that contains the matched line if you specify more than one file in the File parameter. • The fgrep command differs from the grep and egrep commands because it searches for a string instead of searching for a pattern • fgrep is equivalent to grep -F command and it uses a fixed string for search and hence it performs a faster search Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg $ fgrep [OPTIONS] PATTERNS [FILES] $ cat input.txt
  • 6. cut command Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg • Linux cut command is useful for selecting a specific column of a file. • It is used to cut a specific sections by byte position, character, and field and writes them to standard output. • It cuts a line and extracts the text data • Syntax : • $ cut OPTION... [FILE]...
  • 7. Example • $ cat > state.txt Andhra Pradesh Arunachal Pradesh Assam Bihar Chhattisgarh Apply following commands on state.txt: List Without ranges: $ cut -b 1,2,3 state.txt List with ranges : $ cut -b 1-3,5-7 state.txt $ cut -b 1- state.txt $ cut -b -3 state.txt $ cut -c 2,5,7 state.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 8. Paste Command • Paste command is used to join files horizontally (parallel merging) by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output. • When no file is specified, or put dash (“-“) instead of file name, paste reads from standard input and gives output as it is until a interrupt command [Ctrl-c] is given. • Syntax: paste [OPTION]... [FILES]... Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 9. $ cat > capital Itanagar Dispur Hyderabad Patna Raipur $ paste number state capital $ paste -d "|" number state capital 1|Arunachal Pradesh|Itanagar 2|Assam|Dispur 3|Andhra Pradesh|Hyderabad 4|Bihar|Patna 5|Chhattisgrah|Raipur Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Example
  • 10. unmae & wget command $ uname • You can use the command to get the release number, version of Linux, and much more. • The “-a” flag is used to get detailed information. $ wget • You can use the wget command to download the content from the internet; • for instance, the following command will download VirtualBox. $ wget https://download.virtualbox.org/virtualbox/6.1.26/VirtualBox-6.1.26- 145957-Win.exe Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 11. apt-get or –apt command • Most important and most used commands of Ubuntu that works with Ubuntu Advanced Packaging Tool (APT); • You can use this “-apt-get” or “-apt” to install or remove packages • The “apt” requires sudo privileges to successfully execute the command. • Syntax : $ sudo apt install [packagename] • To install vlc media player package use • $ sudo apt install vlc • To remove package - $ sudo apt remove [packagename] Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 12. history command • The history command shows the list of commands (with numeric numbers) executed • $ history • One can execute any of the listed commands • If you want to execute the 2nd command (which is apt update command), then you have to write “!74” to get the result of that command: Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 13. ps command • ps - using the -ps command, you will be able to get the list of processes. $ ps Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 14. w command • W command will display the user details that are currently logged into the system • $ w Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 15. passwd • passwd - With the help of the passwd command, you can change the password of your Ubuntu user: • You must pass “username” to “passwd” to change the password of that; for example, the command given below will change the password of user “6cse01” Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 16. hostname command • This command will print your hostname on the terminal • $ hostname • bitlinux@6cse01 $ bitlinux Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 17. ping command • Ping - you can use the ping command to check the connectivity to your server; • for example, the command below will ping to YouTube and also prints the response time • $ping hostname or ip-address • $ ping youtube.com • $ ping google.com Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 18. $ uptime -shows how long system is running Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 19. $ users – shows username who are currently logged in Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 20. $ service – call and execute script Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg $ service --status-all
  • 21. $ ps – display about running process Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 22. kill, killall and pkill • kill terminates processes based on Process ID number (PID), • While the killall and pkill commands terminate running processes based on their names and other attributes. • Example $ ps PID TTY TIME CMD 11571 pts/20 00:00:00 bash 22166 pts/20 00:00:00 ps $ kill -s 0 11571 $ kill -s 0 11579 bash: kill: (11579) - No such process Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 23. $ pmap – memory map of process Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 24. $ free – shows memory status Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 25. $ netstat – display network status Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 26. $ nslookup – check domain name of ip info Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 27. $ route - list routing table for your server Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 28. ftp command • Here, ftp stands for File Transfer Protocol. This utility helps you upload and download your file from one computer to another computer. • $ftp hostname or ip-address • $ftp 172.16.0.100 • ftp> dir • ftp> get <filename> • ftp> quit • 221 Goodbye. • $ Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 29. More Commands • join • Tee • Comm • Cmp • Diff • tr Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 30. Text Editing with Vi Editor (vi- Visual Editor) Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 31. Vi Editor • The VI editor is a screen based editor used by many unix users. • It is the default editor that comes with the UNIX operating systems and is called vi (visual editor). • The improved version of vi is called the vim editor ( vi improved) is available with Linux systems. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 32. Modes of vi editor • There are three basic modes of vi:- 1. Command mode 2. Insert mode 3. Line mode Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 33. 1. Command mode:- • This the default when you enter vi. • In command mode - most letters, or short sequence of letters, that you type will be interpreted as commands, without explicitly pressing Enter. • If you press ESC when you’re in command mode, your terminal will beep at you. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 34. 2. Insert Mode • Insert mode:- In insert mode, whatever you type is inserted in the file at the cursor position. • Type i to enter insert mode from command mode; • press ESC to end insert mode, and return to command mode. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 35. 3. Line mode • Line mode:- Use line mode to enter line oriented commands. • To enter line mode from command mode, type a colon(:). • Your cursor moves to the bottom of the screen, by a colon prompt. • Type a line mode command and then press ENTER. • Each time you use a line mode command, you must • type a colon to enter line mode, • then type the command by the colon prompt at the bottom of the screen, • then press ENTER when you finish typing the command Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 36. Starting and stopping vi • To edit file $ vi generalnote • Above command starts vi and allocates a memory buffer for file generalnote • If the file already exists, text in the file will be displayed on the screen. • You can't add any text to the file until you go into insert mode because vi started in the command mode. • The tilde character (~) you see in the screen shot shows that the file has no text in these lines. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 37. Starting and stopping vi Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg • The tilde character (~) you see in the screen shot shows that the file has no text in these lines. • To switch to insert mode, press the i character • Press the Esc & : key to return to command mode. • To save file use :w command. • To quit the editor use :q command • Use : x or wq to save and quit in one step
  • 38. Cursor Movement Commands • The mouse does not move the cursor within the vi editor screen. You must have the key commands listed. • Before using any of these commands, make sure that you are in the command mode by pressing the ESC & : key. • You can also instruct the vi editor to display the line number with each line using the :set number command. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Symbol Function l Move one character right h Move one character left j Move one line down k Move one line up < space > Move one character right G Go to last line of the file nG Go to line number n in the file $ Go to end of current line ^ Go to start of line w Go to beginning of next word b Go to beginning of previous word e Move to end of word H Go to first line of screen M Go to middle line of screen L Go to last line of screen ( Go to beginning of sentence ) Go to end of sentence { Go to beginning of paragraph } Go to end of paragraph
  • 39. Inserting text in vi Command Effect i Start inserting text at the current cursor location. I Start inserting text at the beginning of the current line. a Start inserting text at the next character position relative to the current cursor location. A Start inserting text at the end of the current line. o Append a blank line just below the current line and start inserting text from the beginning of that line. O Append a blank line just above the current line and start inserting text from the beginning of that line. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 40. Deleting text in vi Command Effect x Delete character at current cursor location. nx Delete n characters starting at current cursor location. X Delete previous character from the current cursor location. nX Delete n previous characters from the current cursor location. dd Delete current line. db Delete previous word. dw Delete from current cursor location to the end of word. dG Delete to the end of file including current line. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 41. Text replacement command in vi Command Effect r Replace current character remaining in command mode s Replace current character and go to insert mode R Replace multiple characters until the key is pressed cw Change to the beginning of next word cc Change entire line cG Change to the end of file Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 42. Cut, Copy, and Paste Commands Command Effect yy Copy or yank current line nyy Copy n lines starting from current line position p Paste yanked text after the current cursor position P Paste yanked text before the current cursor position :m a Move current line and paste after line number a :a,bmc Move lines from a to b and paste after line number c :a,btc Copy lines from a to b and paste after line number c Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 44. What is in a shell script? • A shell script is a text file that contains a sequence of commands for a UNIX-based operating system. • Shell scripting is an important part of process automation in Linux. • Scripting helps you write a sequence of commands in a file and then execute them. • This saves you time because you don't have to write certain commands again and again Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 45. How to write shell script • Following steps are required to write shell script: • (1) Use any editor like vi or gedit to write shell script. • (2) After writing shell script set execute permission • (3) Execute shell script as • syntax: • bash shell-script-name • sh shell-script-name • ./your-script-name Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 46. First shell script echo "Our first script" echo "--------------------------------------------" echo # This inserts an empty line in output. echo "We are currently in the following directory" pwd echo "This directory contains the following files" ls Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 47. Prog1: Write following shell script, save it, execute it and note down the it's output. $ vi ginfo # # # Script to print user information who currently login , current date & time # clear echo "Hello $USER" echo "Today is c ";date echo "Number of user login : c" ; who | wc -l echo "Calendar" cal exit 0 Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 48. Prog 2 : Using if-else to check whether two numbers are equal a=10 b=20 if [ $a -eq $b ] then echo " Number is equal " else echo " number not equal " fi Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 49. C- Program in Linux Environment Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 50. First C Program Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Steps: • Write program in vi editor • Save with .c extension • Comiple : $ gcc progname.c • Run ; $ ./a.out