SlideShare a Scribd company logo
8
Most read
12
Most read
13
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

PDF
Termux commands-list
PPTX
Vim Editor And Basic Scripting (Ch-7)
PPTX
Terminal Commands (Linux - ubuntu) (part-1)
PPTX
User and groups administrator
PPT
Linux
DOCX
Linux final exam
PPTX
Linux security
ODP
Linux commands
Termux commands-list
Vim Editor And Basic Scripting (Ch-7)
Terminal Commands (Linux - ubuntu) (part-1)
User and groups administrator
Linux
Linux final exam
Linux security
Linux commands

What's hot (20)

PPT
Linux Administration
PPTX
PPT
Linux basic commands
PPTX
Android Architecture.pptx
PDF
Unix - An Introduction
PPTX
Linux.ppt
PDF
Course 102: Lecture 8: Composite Commands
PPTX
Chapter1- Introduction to Computers and the Internet
PPT
User administration concepts and mechanisms
PPTX
Unix Operating System
PPTX
Os ppt
PPTX
what is LINUX ? presentation.
PPTX
Linux basics
PPT
Unix/Linux Basic Commands and Shell Script
PDF
Course 102: Lecture 11: Environment Variables
PPTX
Introduction to c programming
PPTX
Introduction to Unix
PDF
OS - Process Concepts
PDF
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
PPT
Basic 50 linus command
Linux Administration
Linux basic commands
Android Architecture.pptx
Unix - An Introduction
Linux.ppt
Course 102: Lecture 8: Composite Commands
Chapter1- Introduction to Computers and the Internet
User administration concepts and mechanisms
Unix Operating System
Os ppt
what is LINUX ? presentation.
Linux basics
Unix/Linux Basic Commands and Shell Script
Course 102: Lecture 11: Environment Variables
Introduction to c programming
Introduction to Unix
OS - Process Concepts
Linux Training For Beginners | Linux Administration Tutorial | Introduction T...
Basic 50 linus command
Ad

Similar to Command-Line 101 (20)

PPTX
Code tacoma command_line
PDF
Linux cheat sheet
PDF
Linux Cheat Sheet.pdf
PPTX
Linux Fundamentals
PDF
Unix command line concepts
PPTX
(Practical) linux 101
PPTX
various shell commands in unix operating system.pptx
PDF
LinuxCommands (1).pdf
PPT
Linux day 1
PDF
UNIX Command Cheat Sheets
PDF
Linux cheat sheet
PPTX
Linux Command.pptx
PPT
Basic Linux day 1
PDF
Linux intro 2 basic terminal
PPTX
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
PDF
Bash cheat sheet
PDF
Bash cheat sheet
PPTX
2. UNIX OS System Architecture easy.pptx
PDF
Linux Basics
PDF
Linux_Commands.pdf
Code tacoma command_line
Linux cheat sheet
Linux Cheat Sheet.pdf
Linux Fundamentals
Unix command line concepts
(Practical) linux 101
various shell commands in unix operating system.pptx
LinuxCommands (1).pdf
Linux day 1
UNIX Command Cheat Sheets
Linux cheat sheet
Linux Command.pptx
Basic Linux day 1
Linux intro 2 basic terminal
AARAV NAYAN OPERATING SYSTEM LABORATORY PCA
Bash cheat sheet
Bash cheat sheet
2. UNIX OS System Architecture easy.pptx
Linux Basics
Linux_Commands.pdf
Ad

More from Artefactual Systems - AtoM (20)

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

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Machine Learning_overview_presentation.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Machine learning based COVID-19 study performance prediction
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Digital-Transformation-Roadmap-for-Companies.pptx
Electronic commerce courselecture one. Pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine Learning_overview_presentation.pptx
Big Data Technologies - Introduction.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Assigned Numbers - 2025 - Bluetooth® Document
Group 1 Presentation -Planning and Decision Making .pptx
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
MIND Revenue Release Quarter 2 2025 Press Release
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Spectroscopy.pptx food analysis technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine learning based COVID-19 study performance prediction
A comparative analysis of optical character recognition models for extracting...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

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!