SlideShare a Scribd company logo
8
Most read
12
Most read
17
Most read
Command-line 101
GETTING TO
KNOW THE
UNIX/LINUX CLI
https://commons.wikimedia.org/wiki/File:Ken_Thompson_(sitting)_and_Dennis_Ritchie_at_PDP-11_(2876612463).jpg
Warning
http://knowyourmeme.com/memes/i-have-no-idea-what-i-m-doinghttp://nedroid.com/2012/05/honk-the-databus/
What is the Command Line?
A terminal window, is a text-only window in a graphical user interface
(GUI) that emulates a console.
A GUI is a type of human-computer interface (i.e., a system for people to
interact with a computer) that uses windows, icons, pull-down menus and a
pointer and that can be manipulated by a mouse (and usually to some extent
by a keyboard as well).
A command is an instruction telling a computer to do something, such as
launch a program.
A command line interface (CLI) is an all-text display mode that has a
command interpreter running in it and that shows commands, including their
arguments, and other data as they are typed in at the keyboard as well as
the results of most such commands.
A command interpreter, also referred to as a shell, is a program whose
primary function is to read commands that are typed into a console or
terminal window and then execute (i.e., run) them.
From the Linux Information Project (http://www.linfo.org/terminal_window.html)
Navigation
> pwd
Shows the path to the current directory.
(Where am I?)
“print working directory”
Navigation
> ls
List the contents of the current directory
Options:
• -l structured (includes permissions,
owners, access dates) long list format
• -R recursive (show subdirectories too)
• -a all (show hidden system files too)
(What’s in here?)
“list contents”
Navigation
In your terminal, try:
> ls --help
This will list all the available options with brief explanations for
each. Some might not make sense yet – don’t worry. Try a few out! Can
you figure out what the following do?
> ls -r
> ls -A
> ls –s –h –S
Useful CLI tips and tricks
If you want to… Try:
See basic help <command> --help
See the manual for a command man <command>
Exit from manual or page view q
Show last command you entered up arrow
Autocomplete filename or path tab
Kill a process CTRL + c
Jump to beginning of a command CTRL + a
Navigation
> cd <directory name>
Changes to the specified directory
(How do I get over there?)
> cd .. Up one level
> cd ../.. Up two levels (etc.)
> cd ~ Home directory
> cd Home directory
> cd - Change to last directory
“change directory”
READING, CREATING, COPYING, REMOVING, EDITING
http://www.slashfilm.com/hackers-oral-history/
Creating directories
> mkdir <name>
Makes a new directory called <name>
(How can I make a new folder?)
“make directory”
> mkdir –v Verbose – output info after
> mkdir –p Create parents as needed
Deleting directories
> rmdir <name>
Deletes directory called <name>. Directory
MUST be empty for the command to succeed.
(How can I remove an existing folder?)
“remove directory”
> rmdir –v Verbose – output info after
> rmdir –p Delete parents as well
(if also empty – if there are
files in there or other
directories it will fail)
Deleting files
> rm <filename>
Deletes file called <filename>.
(How can I remove an existing file?)
“remove”
> rm -v Verbose – output info after
> rm –i Prompt before every deletion
> rm –r
Recursive – remove subdirs and
contents below as well
> rm –f Force – ignore warnings
DANGER!
rm is a powerful
command, and you can
easily accidentally
delete a lot with the
–r and –f options…
https://steemit.com/health/@kyusho/danger-will-robinson
Copying files
> cp <file1> <file2>
Makes a copy of <file1> in location and with
name of <file2>. Example:
(How can I copy a file to another place?)
“copy”
> cp atom/LICENSE /vagrant/atom-license.txt
NOTE: if /vagrant/atom-license.txt already exists,
then it will be overwritten!
See the manual for other options
Moving files
> mv <file1> <file2>
Moves <file1> to new location <file2>. Can
rename file as part of the operation.
(How can I move a file to another place?)
“move”
NOTE: if <file2> already exists, then it will be
overwritten by the contents of <file1>
See the manual for other options
Reading files
(How can I view the contents of a file?)
> less <filename>
Show 1 page at a time. Space bar
will page through, q to quit
> cat <filename> Print whole file in terminal
> head <filename>
Display first 10 lines of
<filename>
> tail <filename> Display last 10 lines
> tail –f <filename>
Display last 10 lines and
contents as the file grows.
Useful for logs, etc.
Show current date and time > date
See a calendar of the current month > cal
See a calendar of the current year > cal -y
List users logged on to this server > who
Show your username > whoami
List users and session info > w
https://www.therefinedgeek.com.au/index.php/2012/10/02/mcpixel-oh-the-lols-you-will-have/
Clear current commands out of view > clear
Clear current commands out of view > CTRL + L
Show full history of commands in
this session
> history
copy to clipboard in the terminal > CTRL + INSERT
paste from clipboard in terminal > SHIFT + INSERT
Repeat the last command > !!
Exit current session, close terminal > exit
https://www.therefinedgeek.com.au/index.php/2012/10/02/mcpixel-oh-the-lols-you-will-have/
Resources – Cheat Sheets
• FossWire Unix/Linux Command
Reference
• GettingGeneticsDone blog
cheat sheet maintained at
Tufts University
• CheatSheetWorld Unix/Linux
cheat sheet
• LinOxide Linux cheat sheet
There are plenty more out there!
Resources – Tutorials
• LinuxCommand – Learning the Shell tutorial
• LearnPythonTheHardWay – Command Line Crash
Course
• Ryan’s Tutorials – Linux Tutorial
• Learn Enough Society – Learn Enough of the
Command Line to be Dangerous
There are plenty more out there!
Command-Line 101

More Related Content

What's hot (20)

PDF
Course 102: Lecture 8: Composite Commands
Ahmed El-Arabawy
 
PDF
Shell scripting
Ashrith Mekala
 
PPT
Linux presentation
Nikhil Jain
 
PDF
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
PDF
Linux Presentation
nishantsri
 
PDF
Course 102: Lecture 5: File Handling Internals
Ahmed El-Arabawy
 
PPTX
Linux standard file system
Taaanu01
 
PDF
Course 102: Lecture 4: Using Wild Cards
Ahmed El-Arabawy
 
PDF
Unix - An Introduction
Deepanshu Gahlaut
 
PPT
Linux
Gouthaman V
 
PDF
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
PDF
Linux basic commands with examples
abclearnn
 
PPT
Vi editor in linux
Bhumivaghasiya
 
PPT
Linux file system
Burhan Abbasi
 
PPT
Basic command ppt
Rohit Kumar
 
PDF
Linux Directory Structure
Kevin OBrien
 
PPT
Shell Scripting
Gaurav Shinde
 
PDF
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
PDF
Intellij idea tutorial
HarikaReddy115
 
PPT
Linux Administration
Harish1983
 
Course 102: Lecture 8: Composite Commands
Ahmed El-Arabawy
 
Shell scripting
Ashrith Mekala
 
Linux presentation
Nikhil Jain
 
Course 102: Lecture 3: Basic Concepts And Commands
Ahmed El-Arabawy
 
Linux Presentation
nishantsri
 
Course 102: Lecture 5: File Handling Internals
Ahmed El-Arabawy
 
Linux standard file system
Taaanu01
 
Course 102: Lecture 4: Using Wild Cards
Ahmed El-Arabawy
 
Unix - An Introduction
Deepanshu Gahlaut
 
Course 102: Lecture 7: Simple Utilities
Ahmed El-Arabawy
 
Linux basic commands with examples
abclearnn
 
Vi editor in linux
Bhumivaghasiya
 
Linux file system
Burhan Abbasi
 
Basic command ppt
Rohit Kumar
 
Linux Directory Structure
Kevin OBrien
 
Shell Scripting
Gaurav Shinde
 
Course 102: Lecture 13: Regular Expressions
Ahmed El-Arabawy
 
Intellij idea tutorial
HarikaReddy115
 
Linux Administration
Harish1983
 

Similar to Command-Line 101 (20)

PPT
Linux lecture5
ranapoonam1
 
PPT
linux-lecture5 storage fs vm guide for linux.ppt
df3
 
PDF
Linux cheat sheet
Pinaki Mahata Mukherjee
 
ODP
Introduction to LINUX
AVI DHALL
 
PDF
Bash cheat sheet
MRATUNJAI TIWARI
 
PDF
Bash cheat sheet
Jogesh Rao
 
PPT
Introduction to Unix
Sudharsan S
 
PDF
60761 linux
Ritika Ahlawat
 
PPTX
Operating System Laboratory presentation .ppt
PDhivyabharathi2
 
PDF
Linux command-cheat-sheet
Ifshar Ahmad
 
PDF
basic-unix.pdf
OmprakashNath2
 
PPTX
Linux Basic commands and VI Editor
shanmuga rajan
 
PDF
Module 02 Using Linux Command Shell
Tushar B Kute
 
PPT
Linux commands
Meenu Chopra
 
DOC
Linux Shortcuts and Commands:
wensheng wei
 
PPTX
Linux
Srinivas Reddy
 
PPT
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
PPT
disk-operating-system.ppt c sdsommands cd
TanyaMathur21
 
PPTX
Unix_Introduction_BCA.pptx the very basi
Priyadarshini648418
 
PPT
Linux Administration
harirxg
 
Linux lecture5
ranapoonam1
 
linux-lecture5 storage fs vm guide for linux.ppt
df3
 
Linux cheat sheet
Pinaki Mahata Mukherjee
 
Introduction to LINUX
AVI DHALL
 
Bash cheat sheet
MRATUNJAI TIWARI
 
Bash cheat sheet
Jogesh Rao
 
Introduction to Unix
Sudharsan S
 
60761 linux
Ritika Ahlawat
 
Operating System Laboratory presentation .ppt
PDhivyabharathi2
 
Linux command-cheat-sheet
Ifshar Ahmad
 
basic-unix.pdf
OmprakashNath2
 
Linux Basic commands and VI Editor
shanmuga rajan
 
Module 02 Using Linux Command Shell
Tushar B Kute
 
Linux commands
Meenu Chopra
 
Linux Shortcuts and Commands:
wensheng wei
 
HISTORY, TYPES OF EMBEDDED LINUX, COMMANDS,
KesavanT10
 
disk-operating-system.ppt c sdsommands cd
TanyaMathur21
 
Unix_Introduction_BCA.pptx the very basi
Priyadarshini648418
 
Linux Administration
harirxg
 
Ad

More from Artefactual Systems - AtoM (20)

PDF
Artefactual AtoM Priorities November 2024
Artefactual Systems - AtoM
 
PPTX
Things I wish I'd known - AtoM tips, tricks, and gotchas
Artefactual Systems - AtoM
 
PDF
AtoM Community Update: 2019-05
Artefactual Systems - AtoM
 
PPTX
Creating your own AtoM demo data set for re-use with Vagrant
Artefactual Systems - AtoM
 
PPTX
Building the Future Together: AtoM3, Governance, and the Sustainability of Op...
Artefactual Systems - AtoM
 
PPTX
AtoM Implementations
Artefactual Systems - AtoM
 
PPTX
AtoM Data Migrations
Artefactual Systems - AtoM
 
PPTX
Looking Ahead: AtoM's governance, development, and future
Artefactual Systems - AtoM
 
PPTX
Contributing to the AtoM documentation
Artefactual Systems - AtoM
 
PDF
Installing AtoM with Ansible
Artefactual Systems - AtoM
 
PDF
AtoM feature development
Artefactual Systems - AtoM
 
PDF
Constructing SQL queries for AtoM
Artefactual Systems - AtoM
 
PDF
Creating custom themes in AtoM
Artefactual Systems - AtoM
 
PDF
Installing and Upgrading AtoM
Artefactual Systems - AtoM
 
PDF
Get to Know AtoM's Codebase
Artefactual Systems - AtoM
 
PPTX
AtoM's Command Line Tasks - An Introduction
Artefactual Systems - AtoM
 
PPTX
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
Artefactual Systems - AtoM
 
PPTX
An Introduction to AtoM, Archivematica, and Artefactual Systems
Artefactual Systems - AtoM
 
PDF
National Archives of Norway - AtoM and Archivematica intro workshop
Artefactual Systems - AtoM
 
PPTX
Introducing Access to Memory
Artefactual Systems - AtoM
 
Artefactual AtoM Priorities November 2024
Artefactual Systems - AtoM
 
Things I wish I'd known - AtoM tips, tricks, and gotchas
Artefactual Systems - AtoM
 
AtoM Community Update: 2019-05
Artefactual Systems - AtoM
 
Creating your own AtoM demo data set for re-use with Vagrant
Artefactual Systems - AtoM
 
Building the Future Together: AtoM3, Governance, and the Sustainability of Op...
Artefactual Systems - AtoM
 
AtoM Implementations
Artefactual Systems - AtoM
 
AtoM Data Migrations
Artefactual Systems - AtoM
 
Looking Ahead: AtoM's governance, development, and future
Artefactual Systems - AtoM
 
Contributing to the AtoM documentation
Artefactual Systems - AtoM
 
Installing AtoM with Ansible
Artefactual Systems - AtoM
 
AtoM feature development
Artefactual Systems - AtoM
 
Constructing SQL queries for AtoM
Artefactual Systems - AtoM
 
Creating custom themes in AtoM
Artefactual Systems - AtoM
 
Installing and Upgrading AtoM
Artefactual Systems - AtoM
 
Get to Know AtoM's Codebase
Artefactual Systems - AtoM
 
AtoM's Command Line Tasks - An Introduction
Artefactual Systems - AtoM
 
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
Artefactual Systems - AtoM
 
An Introduction to AtoM, Archivematica, and Artefactual Systems
Artefactual Systems - AtoM
 
National Archives of Norway - AtoM and Archivematica intro workshop
Artefactual Systems - AtoM
 
Introducing Access to Memory
Artefactual Systems - AtoM
 
Ad

Recently uploaded (20)

PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PPTX
Machine Learning Benefits Across Industries
SynapseIndia
 
PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PPTX
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
PPTX
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Machine Learning Benefits Across Industries
SynapseIndia
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
python advanced data structure dictionary with examples python advanced data ...
sprasanna11
 
The Future of Artificial Intelligence (AI)
Mukul
 
Basics of Electronics for IOT(actuators ,microcontroller etc..)
arnavmanesh
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 

Command-Line 101

  • 1. Command-line 101 GETTING TO KNOW THE UNIX/LINUX CLI https://commons.wikimedia.org/wiki/File:Ken_Thompson_(sitting)_and_Dennis_Ritchie_at_PDP-11_(2876612463).jpg
  • 3. What is the Command Line? A terminal window, is a text-only window in a graphical user interface (GUI) that emulates a console. A GUI is a type of human-computer interface (i.e., a system for people to interact with a computer) that uses windows, icons, pull-down menus and a pointer and that can be manipulated by a mouse (and usually to some extent by a keyboard as well). A command is an instruction telling a computer to do something, such as launch a program. A command line interface (CLI) is an all-text display mode that has a command interpreter running in it and that shows commands, including their arguments, and other data as they are typed in at the keyboard as well as the results of most such commands. A command interpreter, also referred to as a shell, is a program whose primary function is to read commands that are typed into a console or terminal window and then execute (i.e., run) them. From the Linux Information Project (http://www.linfo.org/terminal_window.html)
  • 4. Navigation > pwd Shows the path to the current directory. (Where am I?) “print working directory”
  • 5. Navigation > ls List the contents of the current directory Options: • -l structured (includes permissions, owners, access dates) long list format • -R recursive (show subdirectories too) • -a all (show hidden system files too) (What’s in here?) “list contents”
  • 6. Navigation In your terminal, try: > ls --help This will list all the available options with brief explanations for each. Some might not make sense yet – don’t worry. Try a few out! Can you figure out what the following do? > ls -r > ls -A > ls –s –h –S
  • 7. Useful CLI tips and tricks If you want to… Try: See basic help <command> --help See the manual for a command man <command> Exit from manual or page view q Show last command you entered up arrow Autocomplete filename or path tab Kill a process CTRL + c Jump to beginning of a command CTRL + a
  • 8. Navigation > cd <directory name> Changes to the specified directory (How do I get over there?) > cd .. Up one level > cd ../.. Up two levels (etc.) > cd ~ Home directory > cd Home directory > cd - Change to last directory “change directory”
  • 9. READING, CREATING, COPYING, REMOVING, EDITING http://www.slashfilm.com/hackers-oral-history/
  • 10. Creating directories > mkdir <name> Makes a new directory called <name> (How can I make a new folder?) “make directory” > mkdir –v Verbose – output info after > mkdir –p Create parents as needed
  • 11. Deleting directories > rmdir <name> Deletes directory called <name>. Directory MUST be empty for the command to succeed. (How can I remove an existing folder?) “remove directory” > rmdir –v Verbose – output info after > rmdir –p Delete parents as well (if also empty – if there are files in there or other directories it will fail)
  • 12. Deleting files > rm <filename> Deletes file called <filename>. (How can I remove an existing file?) “remove” > rm -v Verbose – output info after > rm –i Prompt before every deletion > rm –r Recursive – remove subdirs and contents below as well > rm –f Force – ignore warnings
  • 13. DANGER! rm is a powerful command, and you can easily accidentally delete a lot with the –r and –f options… https://steemit.com/health/@kyusho/danger-will-robinson
  • 14. Copying files > cp <file1> <file2> Makes a copy of <file1> in location and with name of <file2>. Example: (How can I copy a file to another place?) “copy” > cp atom/LICENSE /vagrant/atom-license.txt NOTE: if /vagrant/atom-license.txt already exists, then it will be overwritten! See the manual for other options
  • 15. Moving files > mv <file1> <file2> Moves <file1> to new location <file2>. Can rename file as part of the operation. (How can I move a file to another place?) “move” NOTE: if <file2> already exists, then it will be overwritten by the contents of <file1> See the manual for other options
  • 16. Reading files (How can I view the contents of a file?) > less <filename> Show 1 page at a time. Space bar will page through, q to quit > cat <filename> Print whole file in terminal > head <filename> Display first 10 lines of <filename> > tail <filename> Display last 10 lines > tail –f <filename> Display last 10 lines and contents as the file grows. Useful for logs, etc.
  • 17. Show current date and time > date See a calendar of the current month > cal See a calendar of the current year > cal -y List users logged on to this server > who Show your username > whoami List users and session info > w https://www.therefinedgeek.com.au/index.php/2012/10/02/mcpixel-oh-the-lols-you-will-have/
  • 18. Clear current commands out of view > clear Clear current commands out of view > CTRL + L Show full history of commands in this session > history copy to clipboard in the terminal > CTRL + INSERT paste from clipboard in terminal > SHIFT + INSERT Repeat the last command > !! Exit current session, close terminal > exit https://www.therefinedgeek.com.au/index.php/2012/10/02/mcpixel-oh-the-lols-you-will-have/
  • 19. Resources – Cheat Sheets • FossWire Unix/Linux Command Reference • GettingGeneticsDone blog cheat sheet maintained at Tufts University • CheatSheetWorld Unix/Linux cheat sheet • LinOxide Linux cheat sheet There are plenty more out there!
  • 20. Resources – Tutorials • LinuxCommand – Learning the Shell tutorial • LearnPythonTheHardWay – Command Line Crash Course • Ryan’s Tutorials – Linux Tutorial • Learn Enough Society – Learn Enough of the Command Line to be Dangerous There are plenty more out there!