SlideShare a Scribd company logo
1 of 33
Presented by :-
U.SHANMUGARAJAN
M.SC COMPUTER SCIENCE
THIAGARAJAR COLLEGE
What is Linux?
Linux is the most used open source operating
system.
Everything on a Linux system can be done by
typing commands
History of Linux?
Linux was developed by Linux Torvalds.
On Octoer 5,1991, Linus announced the first
official version of Linux. Which was version 0.02.
What is command shell?
⇨Shell is a Program that takes commands from the
keyboard and gives them to the operating system
to perform.
⇨On most Linux systems a BASH(Bourne-Again
SHell) is the default shell.
⇨Ksh, tcsh and xsh are other shell programs
available on a Linux systems.
⇨Command prompt user’s types.
•$ - “logged in as a regular user”,
•# - “logged in as root”
LINUX BASIC
COMMANDS
A shell script is a text file contains Linux
commands.
We create shell program with any editors such as vi.
Shell scripts allow input/output operations and
manipulating variables.
The sh command used to execute shell program.
the following commands are also used in the
shell programming
1> read – read the variable from the terminal.
eg . read a
2> expr – expression.
eg . ‘expr $a + $b’
add two variables a and b. Note that expr statement
always start with ‘ and end with ‘.
we also use arithmetic operators ‘-’ , ’*’ , ’/’ , ’%’
Shell programming
3> relational operators
-gt - greater than
-lt - less than
-ge - greater than or equal to
-le - less than or equal to
-eq - equal to
4> pipeline ( | )
pipeline used to combine many
commands into one.
eg . Cat $fn | tr “a-z” “A-Z”
It converts all lowercase to upper case and display.
5> cc
compiles c program.
Shell programming
TERMINAL
directory handling commands
1> mkdir – make directories
eg. $mkdir dir1
2> rmdir – remove empty directories
eg. $rmdir dir1
3> cd – changes directories
eg. $cd dir1 (change directory to dir1)
$cd (move to previous directory)
4> pwd – present working directory
eg. $pwd
Display file contents
1> cat – shows contents of the file
eg. $cat file1
we also use cat command for create, copy, append
the file
 cat>file1 – open new file named file1
Cat>>file1 – open file1 for append
Cat file1>file2 – The contents of file1 copied
to file2
use ctrl + d or ctrl + z for save the file.
2> tac – similar to cat but it displays
contents of the file in reverse order
eg. $tac file1
Display file contents
3> head – display first 10 lines of files.
syntax. $head –n filename
4> tail – display last 10 lines of files.
syntax. $tail –n filename
Display file contents
5> more
The more command is useful for displaying
files that take up more than one screen. More will allow
you to see the contents of the file page by page. Use
the space bar to see the next page, or q to quit.
syntax. $more [options] filename
options are
-num - sets the no of lines to be display
` -d - more prompt the user with
the message
‘[press space to continue, ’q’ to quit]’
-f - long lines are wrapped
-s - convert multiple blank line
into one line
Display file contents
6> less
less command similar to more, but it
provides some more options to view file.
space - ahead one full screen
ENTER - ahead one line
b - back one full screen
k - back one line
g - top of the file
G - bottom of the file
/text - search forward for text
n - repeat last search
q - quit
File handling commands
1> ls – List all files and folders
syntax :- ls [option]…[file]
•-a – List files include hidden files.
•-author – print the author of each file
•-B – will not list the backup file ending ~
•-l – List all files with complete details.
•-d – List directories
•-i – print index number of each file
•-s – print size of each file
•-t – sort by modification time.
•-1 – list one file per line.
We combine two or more option to display files.
Eg : ls –la – List all files with complete details include
hidden files.
File handling commands
2> file – It determines the file type.
3> touch – create empty files
eg 1. touch file3
4> rm – remove files or directories
syntax : rm [options] filename
-i - it confirm before delete the files
-f - (force) remove directory contain files.
(only root user use this).
eg . rm file1, rm -f some_dir
File handling commands
5> vi – open Visual text editor
eg. $vi file1.txt, $vi
6> sh – runs shell program
eg. $sh filename
7> cp – copy files and directories
syntax : cp source target
-r - the -r option forces recursive
copying of all files in all
subdirectories.
-i - prevents cp from overwriting
existing file
eg 1. cp sample.txt sample_copy.txt
eg 2. cp sample_copy.txt target_dir
File handling commands
8> mv – move or rename files or
directory
eg 1. mv source.txt target_dir
eg 2. mv old.txt new.txt
9> find – search for files in a directory
eg . find file1.txt, find –name file1.txt
10>chown – change owner of file
File handling commands
11>chmod – change permission of file
0 – No permission
1 – Execute
2 – write
3 – Write and Execute
4 – Read
5 – Read and Execute
6 – Read and Write
7 – All permission
syntax : chmod UGO
U – users
G – groups
O – others
Text Processing commands
1> sort – sort lines of text files
syntax : sort [OPTION] [FILE]
eg. sort file1 - ascending order
sort –r file1 - descending order
sort -n file2 - numeric sort
2> tr – transalate characters in one set to
corresponding characters in another
set
eg. tr 'a-z' 'A-Z' < lowercase.txt
3> echo – display a line of text
eg. echo Linux, echo $HOME
Text Processing commands
4> grep – print lines matching a pattern
Syntax : grep [OPTION] PATTERN [FILE]
eg. grep –i apple sample.txt
i – ignore case
o – only matching
n – print line numbers of matches
v – print lines not containing pattern
5> wc – print the number of lines, words, and
characters in files
eg. wc –l file1.txt - count no of lines in file1
wc –w file1.txt - count no of words
wc –c file1.txt - count no of character
Date – prints system date and time
syntax . $date [options]
eg :- Tuesday, August 23 10:20:32 IST 2016
•+ %d – Day of the months (in digits)
•+ %m – Month of the year (in digits)
•+ %y – Year (last two digits)
•+ % D – Date as mm/dd/yy
•+ %H – Hour (00 to 23)
•+ %M – Minutes (00 to 59)
•+ %S – Seconds (00 to 59)
•+ %T – Time as HH:MM:SS
•+ %a – Weekday (sun to sat)
•+ %h – Month (jan to dec)
•+ %r – Time in the AM/PM notation
Date commands
1> history – prints recently used commands
eg . $history
2> clear – clear the terminal.
eg . $Clear
3> exit – exit from the terminal.
eg . $exit
4> man – get help on entered commands.
eg . $man ls – get help on the ‘ls’ command.
5> who – show who is logged into the system
eg . $who
6> whoami – show current user logged in the
system
eg . $whoami
7> passwd – change password for current user
eg . $passwd
Other Useful commands
8> sudo -i – login as root user
eg . $sudo -i
9> info – display information about the commands.
eg . $info
10> cal – displays the calendar.
eg . $cal
Other Useful commands
Vi editor
Editors are mainly used for creating, deleting and
editing the files.
All systems have two standard editors, they are Ed and
Vi.
Ed allows the user for one line editing only but vi editor
allows the user to edit text of one screen at a time.
What is vi editor
Two modes in vi editor
1)Insert mode
In this input mode, the keyboard behaves as a
normal typewriter with the exception.
2)Command mode
In command mode, all the keys on the keyboard
become editing commands (x keys works as delete key).
Modes in vi editor
Text is inserted. The ‘Esc’ key ends insert mode and return to
command mode.
We enter insert mode with
 ‘i’ - insert
 ’a’ - insert after
 ‘A’ - insert at End Of Line
 ‘o’ - new line after current line
 ‘O’ - new line above current line
Insert mode
letters or sequence of letters interactively command vi. commands
are case sensitive. the ‘Esc’ key can end a command.
Command mode
KEYS ACTIONS
h/j/k/l Move cursor left/down/up/right
Ctrl + d Scroll down one half of a screen
ctrl + u) Scroll up one half of a screen
H (Shift + h) Move cursor to top of the page
L (shift+ l) Move cursor to bottom of the page
w
5w
Move cursor a word at a time
Move cursor 5 words ahead
b
5b
Move cursor back a word at a time
Move cursor back 5 words
Command mode
KEYS ACTIONS
e
3e
Move cursor to end of word
Move cursor ahead to the end of 3rd word
0
:30
Move cursor to beginning of line
Move cursor to line thirty
$ Move cursor to end of line
G Move cursor to end of file
M Mark the line on which the cursor.
i , a, A, o, O Go to insert mode
D
dd
Delete contents of line after cursor
Delete line
Command mode
KEYS ACTIONS
x
X
Delete character at cursor
Delete character before cursor
Y or yy Copy current line into unnamed storage buffer
p
P
Paste unnamed storage buffer after current line
Paste unnamed storage buffer before current line
J Join current and following line into one line
Ctrl – a Increment number under the cursor
Ctrl – x Decrement number under the cursor
. Repeat last command action
Creating a file in VI editor
If we want to edit an existing file or to create a new file with
name student , we have to give the following command.
$vi student
We also create unnamed file as follows
$vi
if we want to create hidden file then we have to give the
following command
$vi .filename
save the file by entering command line mode and type :wq
we save the file in vi editor by going to command mode and press‘:’.
This goes to the another mode called command line mode or last line
mode.
we save the file with following ways.
:ZZ - save changes to current file and quit.
:wq - save(write) changes to current file
and quit
:w - save changes to current file without
quitting
:w filename - save changes to a new file of name
“filename without quitting.
Saving the file
Closing the file
once we created the file, we exit from the vi editor by using
following steps
•go to command line mode.
•use :wq for save file and quit
•use :qa for quit all files
•use :q! for quit file without saving..
Linux Basic commands and VI Editor

More Related Content

What's hot

Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Ahmed El-Arabawy
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Ahmed El-Arabawy
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in LinuxHenry Osborne
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scriptingvceder
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Noé Fernández-Pozo
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsAhmed El-Arabawy
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopessana mateen
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Ahmed El-Arabawy
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell scriptBhavesh Padharia
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Ahmed El-Arabawy
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic CommandsHanan Nmr
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File ManagementDamian T. Gordon
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Ahmed El-Arabawy
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learningLavanya Sharma
 

What's hot (20)

Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities Course 102: Lecture 7: Simple Utilities
Course 102: Lecture 7: Simple Utilities
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
Vi editor
Vi   editorVi   editor
Vi editor
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
Vi editor
Vi editorVi editor
Vi editor
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Vi editor
Vi editorVi editor
Vi editor
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions Course 102: Lecture 13: Regular Expressions
Course 102: Lecture 13: Regular Expressions
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands Course 102: Lecture 3: Basic Concepts And Commands
Course 102: Lecture 3: Basic Concepts And Commands
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands Course 102: Lecture 8: Composite Commands
Course 102: Lecture 8: Composite Commands
 
File system in operating system e learning
File system in operating system e learningFile system in operating system e learning
File system in operating system e learning
 

Similar to Linux Basic commands and VI Editor

Similar to Linux Basic commands and VI Editor (20)

Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
Workshop on command line tools - day 1
Workshop on command line tools - day 1Workshop on command line tools - day 1
Workshop on command line tools - day 1
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Unix
UnixUnix
Unix
 
Linux powerpoint
Linux powerpointLinux powerpoint
Linux powerpoint
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
Unix command
Unix commandUnix command
Unix command
 
Unix slideshare
Unix slideshareUnix slideshare
Unix slideshare
 
Basics of Unix Adminisration
Basics  of Unix AdminisrationBasics  of Unix Adminisration
Basics of Unix Adminisration
 
Basics of UNIX Commands
Basics of UNIX CommandsBasics of UNIX Commands
Basics of UNIX Commands
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Linux Basic commands and VI Editor

  • 1. Presented by :- U.SHANMUGARAJAN M.SC COMPUTER SCIENCE THIAGARAJAR COLLEGE
  • 2. What is Linux? Linux is the most used open source operating system. Everything on a Linux system can be done by typing commands History of Linux? Linux was developed by Linux Torvalds. On Octoer 5,1991, Linus announced the first official version of Linux. Which was version 0.02.
  • 3. What is command shell? ⇨Shell is a Program that takes commands from the keyboard and gives them to the operating system to perform. ⇨On most Linux systems a BASH(Bourne-Again SHell) is the default shell. ⇨Ksh, tcsh and xsh are other shell programs available on a Linux systems. ⇨Command prompt user’s types. •$ - “logged in as a regular user”, •# - “logged in as root”
  • 5. A shell script is a text file contains Linux commands. We create shell program with any editors such as vi. Shell scripts allow input/output operations and manipulating variables. The sh command used to execute shell program. the following commands are also used in the shell programming 1> read – read the variable from the terminal. eg . read a 2> expr – expression. eg . ‘expr $a + $b’ add two variables a and b. Note that expr statement always start with ‘ and end with ‘. we also use arithmetic operators ‘-’ , ’*’ , ’/’ , ’%’ Shell programming
  • 6. 3> relational operators -gt - greater than -lt - less than -ge - greater than or equal to -le - less than or equal to -eq - equal to 4> pipeline ( | ) pipeline used to combine many commands into one. eg . Cat $fn | tr “a-z” “A-Z” It converts all lowercase to upper case and display. 5> cc compiles c program. Shell programming
  • 8. directory handling commands 1> mkdir – make directories eg. $mkdir dir1 2> rmdir – remove empty directories eg. $rmdir dir1 3> cd – changes directories eg. $cd dir1 (change directory to dir1) $cd (move to previous directory) 4> pwd – present working directory eg. $pwd
  • 9. Display file contents 1> cat – shows contents of the file eg. $cat file1 we also use cat command for create, copy, append the file  cat>file1 – open new file named file1 Cat>>file1 – open file1 for append Cat file1>file2 – The contents of file1 copied to file2 use ctrl + d or ctrl + z for save the file. 2> tac – similar to cat but it displays contents of the file in reverse order eg. $tac file1
  • 10. Display file contents 3> head – display first 10 lines of files. syntax. $head –n filename 4> tail – display last 10 lines of files. syntax. $tail –n filename
  • 11. Display file contents 5> more The more command is useful for displaying files that take up more than one screen. More will allow you to see the contents of the file page by page. Use the space bar to see the next page, or q to quit. syntax. $more [options] filename options are -num - sets the no of lines to be display ` -d - more prompt the user with the message ‘[press space to continue, ’q’ to quit]’ -f - long lines are wrapped -s - convert multiple blank line into one line
  • 12. Display file contents 6> less less command similar to more, but it provides some more options to view file. space - ahead one full screen ENTER - ahead one line b - back one full screen k - back one line g - top of the file G - bottom of the file /text - search forward for text n - repeat last search q - quit
  • 13. File handling commands 1> ls – List all files and folders syntax :- ls [option]…[file] •-a – List files include hidden files. •-author – print the author of each file •-B – will not list the backup file ending ~ •-l – List all files with complete details. •-d – List directories •-i – print index number of each file •-s – print size of each file •-t – sort by modification time. •-1 – list one file per line. We combine two or more option to display files. Eg : ls –la – List all files with complete details include hidden files.
  • 14. File handling commands 2> file – It determines the file type. 3> touch – create empty files eg 1. touch file3 4> rm – remove files or directories syntax : rm [options] filename -i - it confirm before delete the files -f - (force) remove directory contain files. (only root user use this). eg . rm file1, rm -f some_dir
  • 15. File handling commands 5> vi – open Visual text editor eg. $vi file1.txt, $vi 6> sh – runs shell program eg. $sh filename 7> cp – copy files and directories syntax : cp source target -r - the -r option forces recursive copying of all files in all subdirectories. -i - prevents cp from overwriting existing file eg 1. cp sample.txt sample_copy.txt eg 2. cp sample_copy.txt target_dir
  • 16. File handling commands 8> mv – move or rename files or directory eg 1. mv source.txt target_dir eg 2. mv old.txt new.txt 9> find – search for files in a directory eg . find file1.txt, find –name file1.txt 10>chown – change owner of file
  • 17. File handling commands 11>chmod – change permission of file 0 – No permission 1 – Execute 2 – write 3 – Write and Execute 4 – Read 5 – Read and Execute 6 – Read and Write 7 – All permission syntax : chmod UGO U – users G – groups O – others
  • 18. Text Processing commands 1> sort – sort lines of text files syntax : sort [OPTION] [FILE] eg. sort file1 - ascending order sort –r file1 - descending order sort -n file2 - numeric sort 2> tr – transalate characters in one set to corresponding characters in another set eg. tr 'a-z' 'A-Z' < lowercase.txt 3> echo – display a line of text eg. echo Linux, echo $HOME
  • 19. Text Processing commands 4> grep – print lines matching a pattern Syntax : grep [OPTION] PATTERN [FILE] eg. grep –i apple sample.txt i – ignore case o – only matching n – print line numbers of matches v – print lines not containing pattern 5> wc – print the number of lines, words, and characters in files eg. wc –l file1.txt - count no of lines in file1 wc –w file1.txt - count no of words wc –c file1.txt - count no of character
  • 20. Date – prints system date and time syntax . $date [options] eg :- Tuesday, August 23 10:20:32 IST 2016 •+ %d – Day of the months (in digits) •+ %m – Month of the year (in digits) •+ %y – Year (last two digits) •+ % D – Date as mm/dd/yy •+ %H – Hour (00 to 23) •+ %M – Minutes (00 to 59) •+ %S – Seconds (00 to 59) •+ %T – Time as HH:MM:SS •+ %a – Weekday (sun to sat) •+ %h – Month (jan to dec) •+ %r – Time in the AM/PM notation Date commands
  • 21. 1> history – prints recently used commands eg . $history 2> clear – clear the terminal. eg . $Clear 3> exit – exit from the terminal. eg . $exit 4> man – get help on entered commands. eg . $man ls – get help on the ‘ls’ command. 5> who – show who is logged into the system eg . $who 6> whoami – show current user logged in the system eg . $whoami 7> passwd – change password for current user eg . $passwd Other Useful commands
  • 22. 8> sudo -i – login as root user eg . $sudo -i 9> info – display information about the commands. eg . $info 10> cal – displays the calendar. eg . $cal Other Useful commands
  • 24. Editors are mainly used for creating, deleting and editing the files. All systems have two standard editors, they are Ed and Vi. Ed allows the user for one line editing only but vi editor allows the user to edit text of one screen at a time. What is vi editor
  • 25. Two modes in vi editor 1)Insert mode In this input mode, the keyboard behaves as a normal typewriter with the exception. 2)Command mode In command mode, all the keys on the keyboard become editing commands (x keys works as delete key). Modes in vi editor
  • 26. Text is inserted. The ‘Esc’ key ends insert mode and return to command mode. We enter insert mode with  ‘i’ - insert  ’a’ - insert after  ‘A’ - insert at End Of Line  ‘o’ - new line after current line  ‘O’ - new line above current line Insert mode
  • 27. letters or sequence of letters interactively command vi. commands are case sensitive. the ‘Esc’ key can end a command. Command mode KEYS ACTIONS h/j/k/l Move cursor left/down/up/right Ctrl + d Scroll down one half of a screen ctrl + u) Scroll up one half of a screen H (Shift + h) Move cursor to top of the page L (shift+ l) Move cursor to bottom of the page w 5w Move cursor a word at a time Move cursor 5 words ahead b 5b Move cursor back a word at a time Move cursor back 5 words
  • 28. Command mode KEYS ACTIONS e 3e Move cursor to end of word Move cursor ahead to the end of 3rd word 0 :30 Move cursor to beginning of line Move cursor to line thirty $ Move cursor to end of line G Move cursor to end of file M Mark the line on which the cursor. i , a, A, o, O Go to insert mode D dd Delete contents of line after cursor Delete line
  • 29. Command mode KEYS ACTIONS x X Delete character at cursor Delete character before cursor Y or yy Copy current line into unnamed storage buffer p P Paste unnamed storage buffer after current line Paste unnamed storage buffer before current line J Join current and following line into one line Ctrl – a Increment number under the cursor Ctrl – x Decrement number under the cursor . Repeat last command action
  • 30. Creating a file in VI editor If we want to edit an existing file or to create a new file with name student , we have to give the following command. $vi student We also create unnamed file as follows $vi if we want to create hidden file then we have to give the following command $vi .filename save the file by entering command line mode and type :wq
  • 31. we save the file in vi editor by going to command mode and press‘:’. This goes to the another mode called command line mode or last line mode. we save the file with following ways. :ZZ - save changes to current file and quit. :wq - save(write) changes to current file and quit :w - save changes to current file without quitting :w filename - save changes to a new file of name “filename without quitting. Saving the file
  • 32. Closing the file once we created the file, we exit from the vi editor by using following steps •go to command line mode. •use :wq for save file and quit •use :qa for quit all files •use :q! for quit file without saving..