SlideShare a Scribd company logo
1 of 21
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

What's hot (20)

Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Basic commands of linux
Basic commands of linuxBasic commands of linux
Basic commands of linux
 
introduction to Web system
introduction to Web systemintroduction to Web system
introduction to Web system
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Introduction to Malware Analysis
Introduction to Malware AnalysisIntroduction to Malware Analysis
Introduction to Malware Analysis
 
Linux Basic Commands
Linux Basic CommandsLinux Basic Commands
Linux Basic Commands
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Linux command ppt
Linux command pptLinux command ppt
Linux command ppt
 
Filepermissions in linux
Filepermissions in linuxFilepermissions in linux
Filepermissions in linux
 
Vi editor
Vi editorVi editor
Vi editor
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Basic 50 linus command
Basic 50 linus commandBasic 50 linus command
Basic 50 linus command
 
Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to Vim
 
Useful Linux and Unix commands handbook
Useful Linux and Unix commands handbookUseful Linux and Unix commands handbook
Useful Linux and Unix commands handbook
 
Introduction to Linux
Introduction to Linux Introduction to Linux
Introduction to Linux
 
Web Security
Web SecurityWeb Security
Web Security
 
Linux
Linux Linux
Linux
 
Linux distributions
Linux    distributionsLinux    distributions
Linux distributions
 
Linux file system
Linux file systemLinux file system
Linux file system
 

Similar to Command-Line 101

Introduction to LINUX
Introduction to LINUXIntroduction to LINUX
Introduction to LINUX
AVI DHALL
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
Sudharsan S
 
Linux Shortcuts and Commands:
Linux Shortcuts and Commands:Linux Shortcuts and Commands:
Linux Shortcuts and Commands:
wensheng wei
 

Similar to Command-Line 101 (20)

Linux lecture5
Linux lecture5Linux lecture5
Linux lecture5
 
Linux cheat sheet
Linux cheat sheetLinux cheat sheet
Linux cheat sheet
 
Introduction to LINUX
Introduction to LINUXIntroduction to LINUX
Introduction to LINUX
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
 
Bash cheat sheet
Bash cheat sheetBash cheat sheet
Bash cheat sheet
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
60761 linux
60761 linux60761 linux
60761 linux
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Linux command-cheat-sheet
Linux command-cheat-sheetLinux command-cheat-sheet
Linux command-cheat-sheet
 
basic-unix.pdf
basic-unix.pdfbasic-unix.pdf
basic-unix.pdf
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Linux Shortcuts and Commands:
Linux Shortcuts and Commands:Linux Shortcuts and Commands:
Linux Shortcuts and Commands:
 
Linux
LinuxLinux
Linux
 
Unix_Introduction_BCA.pptx the very basi
Unix_Introduction_BCA.pptx the very basiUnix_Introduction_BCA.pptx the very basi
Unix_Introduction_BCA.pptx the very basi
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Linux
LinuxLinux
Linux
 
Dos commands new
Dos commands new Dos commands new
Dos commands new
 

More from Artefactual Systems - AtoM

More from Artefactual Systems - AtoM (20)

CSV import in AtoM
CSV import in AtoMCSV import in AtoM
CSV import in AtoM
 
Things I wish I'd known - AtoM tips, tricks, and gotchas
Things I wish I'd known - AtoM tips, tricks, and gotchasThings I wish I'd known - AtoM tips, tricks, and gotchas
Things I wish I'd known - AtoM tips, tricks, and gotchas
 
AtoM Community Update: 2019-05
AtoM Community Update: 2019-05AtoM Community Update: 2019-05
AtoM Community Update: 2019-05
 
Creating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with VagrantCreating your own AtoM demo data set for re-use with Vagrant
Creating your own AtoM demo data set for re-use with Vagrant
 
Searching in AtoM
Searching in AtoMSearching in AtoM
Searching in AtoM
 
Building the Future Together: AtoM3, Governance, and the Sustainability of Op...
Building the Future Together: AtoM3, Governance, and the Sustainability of Op...Building the Future Together: AtoM3, Governance, and the Sustainability of Op...
Building the Future Together: AtoM3, Governance, and the Sustainability of Op...
 
AtoM Implementations
AtoM ImplementationsAtoM Implementations
AtoM Implementations
 
AtoM Data Migrations
AtoM Data MigrationsAtoM Data Migrations
AtoM Data Migrations
 
Looking Ahead: AtoM's governance, development, and future
Looking Ahead: AtoM's governance, development, and futureLooking Ahead: AtoM's governance, development, and future
Looking Ahead: AtoM's governance, development, and future
 
Contributing to the AtoM documentation
Contributing to the AtoM documentationContributing to the AtoM documentation
Contributing to the AtoM documentation
 
Installing AtoM with Ansible
Installing AtoM with AnsibleInstalling AtoM with Ansible
Installing AtoM with Ansible
 
AtoM feature development
AtoM feature developmentAtoM feature development
AtoM feature development
 
Constructing SQL queries for AtoM
Constructing SQL queries for AtoMConstructing SQL queries for AtoM
Constructing SQL queries for AtoM
 
Creating custom themes in AtoM
Creating custom themes in AtoMCreating custom themes in AtoM
Creating custom themes in AtoM
 
Installing and Upgrading AtoM
Installing and Upgrading AtoMInstalling and Upgrading AtoM
Installing and Upgrading AtoM
 
Get to Know AtoM's Codebase
Get to Know AtoM's CodebaseGet to Know AtoM's Codebase
Get to Know AtoM's Codebase
 
AtoM's Command Line Tasks - An Introduction
AtoM's Command Line Tasks - An IntroductionAtoM's Command Line Tasks - An Introduction
AtoM's Command Line Tasks - An Introduction
 
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
AtoM and Vagrant: Installing and Configuring the AtoM Vagrant Box for Local T...
 
An Introduction to AtoM, Archivematica, and Artefactual Systems
An Introduction to AtoM, Archivematica, and Artefactual SystemsAn Introduction to AtoM, Archivematica, and Artefactual Systems
An Introduction to AtoM, Archivematica, and Artefactual Systems
 
National Archives of Norway - AtoM and Archivematica intro workshop
National Archives of Norway - AtoM and Archivematica intro workshopNational Archives of Norway - AtoM and Archivematica intro workshop
National Archives of Norway - AtoM and Archivematica intro workshop
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

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!