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)

PPT
8.1.intro unix
southees
 
PPTX
An Introduction to Linux
Dimas Prasetyo
 
PPT
Linux Commands
Utkarsh Sengar
 
PPT
Linux Basics
sathish sak
 
PPT
IntroCommandLine.ppt
GowthamRaju15
 
PPT
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
PDF
Unit 10 investigating and managing
root_fibo
 
PDF
Unix for Librarians
Ravi Mynampaty
 
PDF
60761 linux
Ritika Ahlawat
 
PPT
Introduction to Unix
Sudharsan S
 
PDF
Unix Basics Commands
Sameeran Jenna
 
PPT
Unit 1-a-brief-history-of-unix-ppt
Rahul Mashal
 
PPT
Linux
sravan kumar
 
PPTX
Linux And perl
Sagar Kumar
 
PPTX
Commands and shell programming (3)
christ university
 
PPT
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
PPTX
Linux powerpoint
bijanshr
 
PPTX
Presentation for RHCE in linux
Kuldeep Tiwari
 
PPTX
Chapter 3 Using Unix Commands
MeenalJabde
 
8.1.intro unix
southees
 
An Introduction to Linux
Dimas Prasetyo
 
Linux Commands
Utkarsh Sengar
 
Linux Basics
sathish sak
 
IntroCommandLine.ppt
GowthamRaju15
 
IntroCommandLine.ppt
TECHWORLDwithphotoed
 
Unit 10 investigating and managing
root_fibo
 
Unix for Librarians
Ravi Mynampaty
 
60761 linux
Ritika Ahlawat
 
Introduction to Unix
Sudharsan S
 
Unix Basics Commands
Sameeran Jenna
 
Unit 1-a-brief-history-of-unix-ppt
Rahul Mashal
 
Linux And perl
Sagar Kumar
 
Commands and shell programming (3)
christ university
 
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
Linux powerpoint
bijanshr
 
Presentation for RHCE in linux
Kuldeep Tiwari
 
Chapter 3 Using Unix Commands
MeenalJabde
 
Ad

Recently uploaded (20)

PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PPTX
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
DOCX
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
PDF
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Next level data operations using Power Automate magic
Andries den Haan
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PPTX
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
Mastering Authorization: Integrating Authentication and Authorization Data in...
Hitachi, Ltd. OSS Solution Center.
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Next level data operations using Power Automate magic
Andries den Haan
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
The birth and death of Stars - earth and life science
rizellemarieastrolo
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 

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 }