SlideShare a Scribd company logo
1 of 35
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 12:44:22
+05'30'
Features of Linux Environment
Features of Linux Operating Systems?
• Free and Open-Source. ...
• Extremely Flexible. ...
• Lightweight Infrastructure. ...
• Graphical User Interface (GUI) ...
• End-to-end encryption. ...
• Portable Environment. ...
• Shell/ Command-line Interface. ...
• Customized keyboard.
• Multiuser, multitasking, portability, security …
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Is shell A Programming Language?
• A Unix shell is both a command interpreter and a programming
language.
• As a command interpreter, the shell provides the user interface to the
rich set of GNU utilities
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Commands.
• $ echo command :
• Echo is a Unix/Linux command tool used for displaying lines of text or string
which are passed as arguments on the command line.
• This is one of the basic command in Linux and most commonly used in shell
scripts.
• $ echo [option] [string]
• $ echo Hello, World!
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Commands..
• who
• date
• pwd
• cd
• mkdir
• rmdir
• ls
• cp
• mv
• rm
• cat
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Date , Time & Calendar
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Basic Commands…
• more command is used to view the text files in the command prompt,
displaying one screen at a time in case the file is large (For example log
files).
• The more command also allows the user do scroll up and down
through the page.
• $ more -d sample.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ more -f sample.txt
-p : This option clears the screen and then displays the text.
-c : This command is used to display the pages on the same area by overlapping the previously
displayed text.
more -c sample.txt
wc command
• wc command gives us useful information about a file by returning no.
of lines, words and bytes
• The first column returned is the number of lines.
• The second is the number of words.
• The third is the number of bytes.
• $ echo test >> test.txt
• $ wc test.txt
1 1 5 test.txt
• Example via pipes, we can count the output of running the ls –al
command:
• $ ls –al |wc
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
find command
• The $ find command can be used to find files or folders matching a
particular search pattern.
• It searches recursively
• Example : Find all the files under the current tree that have the .txt
extension and print the relative path of each file matching:
$ find -name '*.txt‘
• It's important to use quotes around special characters like * to avoid
the shell interpreting them.
• Find directories under the current tree matching the name "src"
$ find . -type d -name src
• You can search under multiple root trees:
$ find folder1 folder2 -name filename.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ head command
• The head command writes to standard output a specified number of
lines or bytes of each of the specified files, or of the standard input.
• If no flag is specified with the head command, the first 10 lines are
displayed by default
• The File parameter specifies the names of the input files.
• Example :
$ nano example1.txt
• Add following lines in file
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
example1.txt :
Connecticut
Delaware
Georgia
Maryland
Massachusetts
New Hampshire
New Jersey
New York
North Carolina
Pennsylvania
Rhode Island
South Carolina
Virginia
Save and exit the file (press Ctrl+X and then Y to confirm)
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ cat example1.txt
$ head example1.txt
• For displaying number of lines –
$ head -n 4 example1.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• For displaying no. of bytes : use the -c (--bytes) argument
• To see 20 bytes of output of the sample file, you would run
$ head -c 20 example1.txt
• For displaying filename tag : To display the file name before
outputting the first 10 lines, add the -v (--verbose) option:
$ head -v example1.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Displaying Multiple Files with head
• You can also display the first lines of multiple files using a single
command:
$ head [option] file_name1 file_name2
$ head example1.txt example2.txt
$ head -n 4 example1.txt example2.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Redirecting output to a text file
• You can redirect the output from the head command to a text file (or
log file) using the greater-than sign (>).
• Instead of displaying the lines in standard output, they are placed into
the wanted file.
• Syntax for redirecting output from head command is :
$ head [options] file_name > output_file
• To redirect the first 10 lines of example1.txt to a file
named output1.txt, you would run the command:
$ head example1.txt > output1.txt
$ cat output1.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Using head with Pipeline
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• head can be piped to one or more commands to modify the output:
• Syntax:
[command] | head [option]
• For example, to list files in the /etc directory using the ls command and
print 10 entries, you would run the command:
$ ls /etc | head
$ tail
• tail command prints the last few number of lines (10 lines by default)
of a certain file, then terminates.
• By default “tail” prints the last 10 lines of a file, then exits.
• This is great for watching log files, for example:
tail -f /var/log/system.log
$ ctrl-C
$ tail -n 10 <filename>
• You can print the whole file content starting from a specific line using +
before the line number:
tail -n +10 <filename>
• $ tail can do much more and as always my advice is to check man tail
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
$ sort command
• SORT command is used to sort a file, arranging the records in a
particular order.
• By default, the sort command sorts file assuming the contents are
ASCII.
• Using options in the sort command can also be used to sort
numerically.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• $ cat > file.txt
abhishek
chitransh
satish
rajan
naveen
divyam
harsh
• $ sort file.txt
• Output :
abhishek
chitransh
divyam
harsh
naveen
rajan
Satish
Note: This command does not
actually change the input file
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Create a data file
$ nl command
• The nl command reads the
File parameter (standard
input by default), numbers
the lines in the input, and
writes the numbered lines to
standard output.
• nl command is a Unix/Linux
utility that is used for
numbering lines, accepting
input either from a file or
from STDIN.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• $ cat list.txt
apples
oranges
potatoes
lemons
garlic
• $ nl list.txt
1 apples
2 oranges
3 potatoes
4 lemons
5 garlic
• $ nl list.txt > nlist.txt
• $ cat nlist.txt
1 apples
2 oranges
3 potatoes
4 lemons
5 garlic
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Example of nl command
In the example above, we run the same nl command, but
redirect the output to a new file, nlist.txt. Then we use cat to
display the results.
$ uniq command
• Linux uniq command is used to remove all the repeated lines from a
file.
• Also, it can be used to display a count of any word, only repeated lines,
ignore characters, and compare specific fields
• Syntax :
$ uniq [OPTION]... [INPUT [OUTPUT]]
• Some useful command line options of the uniq command are as following:
• -c, --count: it prefixes the lines by the number of occurrences.
• -d, --repeated: it is used to print duplicate lines, one for each group.
• -D: It is used to print all the duplicate lines.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
• Remove repeated lines
$ sort filename.txt | uniq
• Counting occurences of word
• $ sort filename.txt | uniq –c
• Displaying repeated lines -d
• $ sort filename.txt | uniq –d
• Display unique lines - u option
$ sort filename.txt | uniq –u
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Examples of uniq command
Linux Funny Commands
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
1. Command: sl (Steam Locomotive)
• $ sl
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
2. telnet towel.blinkenlights.nl
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
telnet towel.blinkenlights.nl
3. Fortune
• $ fortune - gives random funny fortune
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
4. Factor
• $ factor 1111
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
5. cowsay
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
6. banner
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
7. figlet
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
8. cmatrix
• You might have seen the Hollywood movie ‘matrix‘ & fascinated with.
• For displaying an animation that looks like Hacker‘s desktop.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Linux Command Line Features

More Related Content

Similar to Linux Command Line Features

1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdfamaresh6333
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSMohamed Abdallah
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPriyadarshini648418
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadOnline Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadRavikumar Nandigam
 
linux commands that might be helpful.pptx
linux commands that might be helpful.pptxlinux commands that might be helpful.pptx
linux commands that might be helpful.pptxMeghrajPatil11
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scriptsPrashantTechment
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unixTeja Bheemanapally
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unixTeja Bheemanapally
 
Linux commands
Linux commandsLinux commands
Linux commandsMannu Khani
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAaravNayan
 
35 ls Command Examples in Linux (The Complete Guide).pdf
35 ls Command Examples in Linux (The Complete Guide).pdf35 ls Command Examples in Linux (The Complete Guide).pdf
35 ls Command Examples in Linux (The Complete Guide).pdfMangesh Dhulap
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppthazhamina
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptxGuhanSenthil2
 

Similar to Linux Command Line Features (20)

1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf1) List currently running jobsANS) see currently runningcommand.pdf
1) List currently running jobsANS) see currently runningcommand.pdf
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
Group13
Group13Group13
Group13
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in HyderabadOnline Training in Unix Linux Shell Scripting in Hyderabad
Online Training in Unix Linux Shell Scripting in Hyderabad
 
linux commands that might be helpful.pptx
linux commands that might be helpful.pptxlinux commands that might be helpful.pptx
linux commands that might be helpful.pptx
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Linux commands
Linux commandsLinux commands
Linux commands
 
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCAAARAV NAYAN OPERATING SYSTEM LABORATORY PCA
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
 
Lpt lopsa
Lpt lopsaLpt lopsa
Lpt lopsa
 
35 ls Command Examples in Linux (The Complete Guide).pdf
35 ls Command Examples in Linux (The Complete Guide).pdf35 ls Command Examples in Linux (The Complete Guide).pdf
35 ls Command Examples in Linux (The Complete Guide).pdf
 
workshop_1.ppt
workshop_1.pptworkshop_1.ppt
workshop_1.ppt
 
LINUX_admin_commands.pptx
LINUX_admin_commands.pptxLINUX_admin_commands.pptx
LINUX_admin_commands.pptx
 
Linux Basics.pptx
Linux Basics.pptxLinux Basics.pptx
Linux Basics.pptx
 

More from BIT DURG

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOMBIT 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
 
MySQL
MySQL MySQL
MySQL 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
 
Oss the freedom dpm 2018
Oss the freedom dpm 2018Oss the freedom dpm 2018
Oss the freedom dpm 2018BIT 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
 
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
 
Oss the freedom dpm 2018
Oss the freedom dpm 2018Oss the freedom dpm 2018
Oss the freedom dpm 2018
 

Recently uploaded

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(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
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
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
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
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
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
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
 
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
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 

Recently uploaded (20)

HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
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
 
(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...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
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
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
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...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
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...
 
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 )
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 

Linux Command Line Features

  • 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 12:44:22 +05'30'
  • 2. Features of Linux Environment
  • 3. Features of Linux Operating Systems? • Free and Open-Source. ... • Extremely Flexible. ... • Lightweight Infrastructure. ... • Graphical User Interface (GUI) ... • End-to-end encryption. ... • Portable Environment. ... • Shell/ Command-line Interface. ... • Customized keyboard. • Multiuser, multitasking, portability, security … Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 4. Is shell A Programming Language? • A Unix shell is both a command interpreter and a programming language. • As a command interpreter, the shell provides the user interface to the rich set of GNU utilities Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 5. Basic Commands. • $ echo command : • Echo is a Unix/Linux command tool used for displaying lines of text or string which are passed as arguments on the command line. • This is one of the basic command in Linux and most commonly used in shell scripts. • $ echo [option] [string] • $ echo Hello, World! Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 6. Basic Commands.. • who • date • pwd • cd • mkdir • rmdir • ls • cp • mv • rm • cat Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 7. Date , Time & Calendar Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 8. Basic Commands… • more command is used to view the text files in the command prompt, displaying one screen at a time in case the file is large (For example log files). • The more command also allows the user do scroll up and down through the page. • $ more -d sample.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 9. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg $ more -f sample.txt -p : This option clears the screen and then displays the text. -c : This command is used to display the pages on the same area by overlapping the previously displayed text. more -c sample.txt
  • 10. wc command • wc command gives us useful information about a file by returning no. of lines, words and bytes • The first column returned is the number of lines. • The second is the number of words. • The third is the number of bytes. • $ echo test >> test.txt • $ wc test.txt 1 1 5 test.txt • Example via pipes, we can count the output of running the ls –al command: • $ ls –al |wc Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 11. find command • The $ find command can be used to find files or folders matching a particular search pattern. • It searches recursively • Example : Find all the files under the current tree that have the .txt extension and print the relative path of each file matching: $ find -name '*.txt‘ • It's important to use quotes around special characters like * to avoid the shell interpreting them. • Find directories under the current tree matching the name "src" $ find . -type d -name src • You can search under multiple root trees: $ find folder1 folder2 -name filename.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 12. $ head command • The head command writes to standard output a specified number of lines or bytes of each of the specified files, or of the standard input. • If no flag is specified with the head command, the first 10 lines are displayed by default • The File parameter specifies the names of the input files. • Example : $ nano example1.txt • Add following lines in file Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 13. example1.txt : Connecticut Delaware Georgia Maryland Massachusetts New Hampshire New Jersey New York North Carolina Pennsylvania Rhode Island South Carolina Virginia Save and exit the file (press Ctrl+X and then Y to confirm) Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 14. $ cat example1.txt $ head example1.txt • For displaying number of lines – $ head -n 4 example1.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 15. • For displaying no. of bytes : use the -c (--bytes) argument • To see 20 bytes of output of the sample file, you would run $ head -c 20 example1.txt • For displaying filename tag : To display the file name before outputting the first 10 lines, add the -v (--verbose) option: $ head -v example1.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 16. Displaying Multiple Files with head • You can also display the first lines of multiple files using a single command: $ head [option] file_name1 file_name2 $ head example1.txt example2.txt $ head -n 4 example1.txt example2.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 17. Redirecting output to a text file • You can redirect the output from the head command to a text file (or log file) using the greater-than sign (>). • Instead of displaying the lines in standard output, they are placed into the wanted file. • Syntax for redirecting output from head command is : $ head [options] file_name > output_file • To redirect the first 10 lines of example1.txt to a file named output1.txt, you would run the command: $ head example1.txt > output1.txt $ cat output1.txt Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 18. Using head with Pipeline Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg • head can be piped to one or more commands to modify the output: • Syntax: [command] | head [option] • For example, to list files in the /etc directory using the ls command and print 10 entries, you would run the command: $ ls /etc | head
  • 19. $ tail • tail command prints the last few number of lines (10 lines by default) of a certain file, then terminates. • By default “tail” prints the last 10 lines of a file, then exits. • This is great for watching log files, for example: tail -f /var/log/system.log $ ctrl-C $ tail -n 10 <filename> • You can print the whole file content starting from a specific line using + before the line number: tail -n +10 <filename> • $ tail can do much more and as always my advice is to check man tail Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 20. $ sort command • SORT command is used to sort a file, arranging the records in a particular order. • By default, the sort command sorts file assuming the contents are ASCII. • Using options in the sort command can also be used to sort numerically. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 21. • $ cat > file.txt abhishek chitransh satish rajan naveen divyam harsh • $ sort file.txt • Output : abhishek chitransh divyam harsh naveen rajan Satish Note: This command does not actually change the input file Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Create a data file
  • 22. $ nl command • The nl command reads the File parameter (standard input by default), numbers the lines in the input, and writes the numbered lines to standard output. • nl command is a Unix/Linux utility that is used for numbering lines, accepting input either from a file or from STDIN. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 23. • $ cat list.txt apples oranges potatoes lemons garlic • $ nl list.txt 1 apples 2 oranges 3 potatoes 4 lemons 5 garlic • $ nl list.txt > nlist.txt • $ cat nlist.txt 1 apples 2 oranges 3 potatoes 4 lemons 5 garlic Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Example of nl command In the example above, we run the same nl command, but redirect the output to a new file, nlist.txt. Then we use cat to display the results.
  • 24. $ uniq command • Linux uniq command is used to remove all the repeated lines from a file. • Also, it can be used to display a count of any word, only repeated lines, ignore characters, and compare specific fields • Syntax : $ uniq [OPTION]... [INPUT [OUTPUT]] • Some useful command line options of the uniq command are as following: • -c, --count: it prefixes the lines by the number of occurrences. • -d, --repeated: it is used to print duplicate lines, one for each group. • -D: It is used to print all the duplicate lines. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 25. • Remove repeated lines $ sort filename.txt | uniq • Counting occurences of word • $ sort filename.txt | uniq –c • Displaying repeated lines -d • $ sort filename.txt | uniq –d • Display unique lines - u option $ sort filename.txt | uniq –u Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg Examples of uniq command
  • 27. 1. Command: sl (Steam Locomotive) • $ sl Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 29. 3. Fortune • $ fortune - gives random funny fortune Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 30. 4. Factor • $ factor 1111 Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg
  • 34. 8. cmatrix • You might have seen the Hollywood movie ‘matrix‘ & fascinated with. • For displaying an animation that looks like Hacker‘s desktop. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg