SlideShare a Scribd company logo
Mastering the UNIX Command Line

           Howard Mao


          March 28, 2013
UNIX




       Created by Ken Thompson and Dennis Ritchie in 1970
       Modern descendants include Linux, OSX, and BSD
Looking up Information




      Man Pages: man <command>
      Google is your friend
      Stackexchange Sites
          stackoverflow.com
          serverfault.com
          superuser.com
          unix.stackexchange.com
Basic Filesystem Navigation




       look around - ls
       move about - cd, pushd, popd
       move, copy, delete - mv, cp, rm
       file info - stat, du, file
       changing permissions - chmod, chown
More About Permissions


      Three types of permissions: read (r), write (w), execute (x)
      Three categories: user (u), group (g), other (o)
      Also represented by an octal number: read (4), write (2),
      execute (1)
      Add them together to get number. One octal digit for each
      category
      Ex. 644 means read + write for user, read only for group
      and other, execute for nobody
      Execute permission for directory means you can list files in
      directory
Globbing




      Match everything *
      Choices {foo,bar,baz}
      Characters [abc]
      Numbers {0..5}
The Almighty Find



   Find allows you to search for files
       By Name: find . -name *.txt
       By Type: find . -type d
       By Timestamp: find . -mtime 1
       And many many more
   Can also run commands on files
   find . -name .txt -exec rm {} ;
I/O Redirection




      I/O Commands: echo, cat, less
      Input from File: command < input.txt
      Output to File: command > output.txt
      Pipes : command1 | command2
Filters




          Search lines with grep
          Find and Replace with sed
          Select columns with cut and awk
Manipulating Processes




      Start in background: command &
      One after another: command1; command2
      If successful, then: command1 && command2
      If unsuccessful, then: command1 || command2
      Suspend and resume: command <Ctrl>+Z; [bg|fg]
      See running procs: ps, ps -au $USER, ps aux
Networking




      Server info - ping, traceroute, host, whois
      Sending raw traffic - nc, telnet
      The World Wide Web - wget, curl
      What’s my address? - ip addr, ip link
      What ports are open - ss, nmap
      Who’s on the port - lsof
Scripting



       Believe it or not, the shell is turing complete
       Variables : VAR=abc
       If statements : if [ "$VAR" ]; then echo $VAR; fi
       For loops : for i in {1..5}; do echo $i; done
       While loops : while true; do echo "forever"; done
       User input : read var; echo $var
       Functions : function func () { do something }

More Related Content

What's hot (20)

PDF
Unix Command-Line Cheat Sheet BTI2014
Noé Fernández-Pozo
 
PDF
Unix / Linux Command Reference
Sumankumar Panchal
 
PDF
Basic linux commands
Raghav Arora
 
PPT
Linux50commands
NIRMAL FELIX
 
PDF
Chapter21 separate-header-and-implementation-files
Deepak Singh
 
PDF
Fast and cost effective geospatial analysis pipeline with AWS lambda
Mila Frerichs
 
PDF
[PDF] 2021 Termux basic commands list
nisivaasdfghj
 
PDF
Linux cheat-sheet
Craig Cannon
 
ODP
Bullwinkle introduction
Turner England
 
PDF
Writing file system in CPython
delimitry
 
PPTX
Linux tech talk
Prince Raj
 
PPTX
Comets notes
Ilija Dukovski
 
PDF
2.1.using the shell
donv214
 
PDF
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
PDF
Mac OSX Terminal 101
Murugun Murugun
 
PPT
Linux commands
U.P Police
 
PPTX
(Practical) linux 101
Arie Bregman
 
PPTX
Linux comands for Hadoop
PM Venkatesha Babu
 
PPT
Basic command ppt
Rohit Kumar
 
PDF
Protostar VM - Heap3
UTD Computer Security Group
 
Unix Command-Line Cheat Sheet BTI2014
Noé Fernández-Pozo
 
Unix / Linux Command Reference
Sumankumar Panchal
 
Basic linux commands
Raghav Arora
 
Linux50commands
NIRMAL FELIX
 
Chapter21 separate-header-and-implementation-files
Deepak Singh
 
Fast and cost effective geospatial analysis pipeline with AWS lambda
Mila Frerichs
 
[PDF] 2021 Termux basic commands list
nisivaasdfghj
 
Linux cheat-sheet
Craig Cannon
 
Bullwinkle introduction
Turner England
 
Writing file system in CPython
delimitry
 
Linux tech talk
Prince Raj
 
Comets notes
Ilija Dukovski
 
2.1.using the shell
donv214
 
Linux Bash Shell Cheat Sheet for Beginners
Davide Ciambelli
 
Mac OSX Terminal 101
Murugun Murugun
 
Linux commands
U.P Police
 
(Practical) linux 101
Arie Bregman
 
Linux comands for Hadoop
PM Venkatesha Babu
 
Basic command ppt
Rohit Kumar
 
Protostar VM - Heap3
UTD Computer Security Group
 

Viewers also liked (17)

PPT
Basic Unix
Rajesh Kumar
 
PDF
Unix command
Atul Pant
 
PPT
Linux command ppt
kalyanineve
 
ODP
Unix tips and tricks
Aleksandar Bilanovic
 
TXT
Unix
Shohan Ahmed
 
PPTX
Unix
Erm78
 
PDF
The Unix Command Line | Jim Reevior
Oomph, Inc.
 
PDF
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
PDF
What's New in IBM MQ - Version 8
MarkTaylorIBM
 
PPT
websphere MQ training Online
Divya Angel
 
PDF
Linux introduction (eng)
Anatoliy Okhotnikov
 
PDF
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
PPTX
NTXISSACSC2 - Threat Modeling Part 2 - STRIDE by Brad Andrews
North Texas Chapter of the ISSA
 
PDF
Websphere MQ (MQSeries) fundamentals
Biju Nair
 
PDF
IBM MQ V9 Overview
MarkTaylorIBM
 
PDF
Unix Command Line Productivity Tips
Keith Bennett
 
PPT
Unix command-line tools
Eric Wilson
 
Basic Unix
Rajesh Kumar
 
Unix command
Atul Pant
 
Linux command ppt
kalyanineve
 
Unix tips and tricks
Aleksandar Bilanovic
 
Unix
Erm78
 
The Unix Command Line | Jim Reevior
Oomph, Inc.
 
SGN Introduction to UNIX Command-line 2015 part 1
solgenomics
 
What's New in IBM MQ - Version 8
MarkTaylorIBM
 
websphere MQ training Online
Divya Angel
 
Linux introduction (eng)
Anatoliy Okhotnikov
 
Introduction to UNIX Command-Lines with examples
Noé Fernández-Pozo
 
NTXISSACSC2 - Threat Modeling Part 2 - STRIDE by Brad Andrews
North Texas Chapter of the ISSA
 
Websphere MQ (MQSeries) fundamentals
Biju Nair
 
IBM MQ V9 Overview
MarkTaylorIBM
 
Unix Command Line Productivity Tips
Keith Bennett
 
Unix command-line tools
Eric Wilson
 
Ad

Similar to Mastering the Unix Command Line (20)

PPTX
Unix Trainning Doc.pptx
KalpeshRaut7
 
PPT
linux-lecture4.ppt
LuigysToro
 
PDF
3.1.a linux commands reference
Acácio Oliveira
 
PPTX
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
PPTX
Linux Commands all presentation file .pptx
AshutoshPrajapati30
 
PPT
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
PPT
Bootcamp linux commands
NexThoughts Technologies
 
PPTX
Using linux in schools
saeed7878
 
PPT
Linux commands and file structure
Sreenatha Reddy K R
 
PPTX
Unix Shell Script - 2 Days Session.pptx
Rajesh Kumar
 
DOC
58518522 study-aix
homeworkping3
 
PDF
Unix _linux_fundamentals_for_hpc-_b
Mohammad Reza Beygi
 
PPT
8.1.intro unix
southees
 
PDF
Information about linux operating system
PriyankaMate4
 
PDF
Module 02 Using Linux Command Shell
Tushar B Kute
 
PDF
basic-unix.pdf
OmprakashNath2
 
PPT
Unix fundamentals
Dima Gomaa
 
PPT
Online Training in Unix Linux Shell Scripting in Hyderabad
Ravikumar Nandigam
 
PPT
3. intro
Harsh Shrimal
 
PPSX
Unix environment [autosaved]
Er Mittinpreet Singh
 
Unix Trainning Doc.pptx
KalpeshRaut7
 
linux-lecture4.ppt
LuigysToro
 
3.1.a linux commands reference
Acácio Oliveira
 
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
Linux Commands all presentation file .pptx
AshutoshPrajapati30
 
linux-lecture4.pptuyhbjhbiibihbiuhbbihbi
YajnadattaPattanayak
 
Bootcamp linux commands
NexThoughts Technologies
 
Using linux in schools
saeed7878
 
Linux commands and file structure
Sreenatha Reddy K R
 
Unix Shell Script - 2 Days Session.pptx
Rajesh Kumar
 
58518522 study-aix
homeworkping3
 
Unix _linux_fundamentals_for_hpc-_b
Mohammad Reza Beygi
 
8.1.intro unix
southees
 
Information about linux operating system
PriyankaMate4
 
Module 02 Using Linux Command Shell
Tushar B Kute
 
basic-unix.pdf
OmprakashNath2
 
Unix fundamentals
Dima Gomaa
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Ravikumar Nandigam
 
3. intro
Harsh Shrimal
 
Unix environment [autosaved]
Er Mittinpreet Singh
 
Ad

Recently uploaded (20)

PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 

Mastering the Unix Command Line

  • 1. Mastering the UNIX Command Line Howard Mao March 28, 2013
  • 2. UNIX Created by Ken Thompson and Dennis Ritchie in 1970 Modern descendants include Linux, OSX, and BSD
  • 3. Looking up Information Man Pages: man <command> Google is your friend Stackexchange Sites stackoverflow.com serverfault.com superuser.com unix.stackexchange.com
  • 4. Basic Filesystem Navigation look around - ls move about - cd, pushd, popd move, copy, delete - mv, cp, rm file info - stat, du, file changing permissions - chmod, chown
  • 5. More About Permissions Three types of permissions: read (r), write (w), execute (x) Three categories: user (u), group (g), other (o) Also represented by an octal number: read (4), write (2), execute (1) Add them together to get number. One octal digit for each category Ex. 644 means read + write for user, read only for group and other, execute for nobody Execute permission for directory means you can list files in directory
  • 6. Globbing Match everything * Choices {foo,bar,baz} Characters [abc] Numbers {0..5}
  • 7. The Almighty Find Find allows you to search for files By Name: find . -name *.txt By Type: find . -type d By Timestamp: find . -mtime 1 And many many more Can also run commands on files find . -name .txt -exec rm {} ;
  • 8. I/O Redirection I/O Commands: echo, cat, less Input from File: command < input.txt Output to File: command > output.txt Pipes : command1 | command2
  • 9. Filters Search lines with grep Find and Replace with sed Select columns with cut and awk
  • 10. Manipulating Processes Start in background: command & One after another: command1; command2 If successful, then: command1 && command2 If unsuccessful, then: command1 || command2 Suspend and resume: command <Ctrl>+Z; [bg|fg] See running procs: ps, ps -au $USER, ps aux
  • 11. Networking Server info - ping, traceroute, host, whois Sending raw traffic - nc, telnet The World Wide Web - wget, curl What’s my address? - ip addr, ip link What ports are open - ss, nmap Who’s on the port - lsof
  • 12. Scripting Believe it or not, the shell is turing complete Variables : VAR=abc If statements : if [ "$VAR" ]; then echo $VAR; fi For loops : for i in {1..5}; do echo $i; done While loops : while true; do echo "forever"; done User input : read var; echo $var Functions : function func () { do something }