SlideShare a Scribd company logo
Code Tacoma:
Command Line Basics
Andrea Urban
September 8, 2018
Please sit next to someone with an operating system
similar to yours.
Agenda
1. Installation and Set up: 15 minutes
2. Introductions
3. Introduction to the Command Line
4. Basic Commands
Installation and Setup
Mac/unix/linux: Open terminal
Windows: 3 options
● If you want to be a developer, but not interested in python (fastest install): Install Git Tools for Windows from the
following URL: https://git-scm.com/download/win. When prompted in the installation wizard, select: "Use Git and
optional Unix tools for the Windows Command Prompt". Open the git bash.
● If you want to learn python too: Install anaconda https://conda.io/docs/user-guide/install/windows.html. Don't do
miniconda; do the full anaconda installer. Choose Python 3.6. Open the anaconda prompt and type ‘conda create -n
main m2-base’. Say y to all queries. When Install is complete type “conda activate main” (To practice command line
commands in future, you’ll need to type last command every time you reopen conda prompt.
● Big installation (not recommended): Install cygwin https://www.cygwin.com/ (a virtual unix machine for windows). I
would not recommend this option because it's a really large program. However, if it's already installed, then you're
ready.
When you’re ready:
Compare your screen to your neighbor’s.
Check with another neighbor.
Ground Rules
If you have any trouble sounding condescending, find a UNIX
user to show you how it's done.
— Scott Adams, Dilbert Cartoonist
● Don’t act like a “UNIX user”.
● Mission: Learn UNIX tools and help others learn them too.
Introductions
Who am I?
● Andrea Urban
● Data scientist
● I mostly work in Python and SQL in Windows. In a past life, I used a Unix
machine coding in Fortran.
Who are you?
● Name
● Why are you interested in learning command line?
● Do you know any programming languages?
CLI: Command Line Interface
A text interface for interacting with a computer.
GUI: Graphical User Interface
Use mouse to interact with
computer.
Drag windows and files around.
CLI:
Command
Line Interface
GUI: Graphical
User Interface
Why is it useful to learn the command line?
Bulk actions - Ex: Delete all the jpg’s in a folder
Connecting to remote servers
Many remote servers only allow you to connect via a terminal.
Remote server interface gui could be slow compared to terminal.
Any other reasons?
Let’s get started!
The prompt
What do you see in your terminal?
Puffy-Cloud:~ Andrea$
● Puffy-Cloud = my computer’s name
● ~ = where I am located in my file system
● Andrea = my user name
What your prompt may look like…
>
$
Any others?
pwd: Where are we?
> pwd
What do you see?
pwd = print working directory
Tells you where you are in your file system.
cd: Take me home.
“cd” stands for “Change Directories”
> cd
Take me to my home directory
~ : refers to home directory (> cd ~ also takes user home)
(Joke: There is no place like ~)
What output do you see?
> cd ..
Take me up a directory
What output do you see? How can you check if this worked?
cd: Take me home.
“cd” stands for “Change Directories”
> cd
> cd ../..
Take me up two directories
Be sure to check your work.
Self-check:
How do I go home?
How do I go up three directories?
ls: Take a look around
> cd First go back home.
ls stands for “list” contents
> ls
List current directory’s contents
What do you see?
> ls ..
Lists contents of directory above current directory
Now what do you see?
ls: Take a look around
> cd
> ls -l
Show long format of contents of directory
> man ls
Show manual pages for the ls command. Use arrow keys to navigate.
Useful for learning about new flags (-l is a flag)
Use the man pages to find out what ls -l is showing you.
Self-check
What will you see if you try the following command? Take a guess before typing it
in the terminal
> ls ../..
How can I print out the file size in human-readable format, i.e., 3.5K instead of
3536 bytes?
(Hint: take a look at the man page for ls)
Hidden Files
> cd
> ls -a
List ALL the contents of the current directory, including hidden files
Hidden files generally start with a period “.”
The hidden files: “.” and “..” represent the current and parent directory
What do you expect to happen when you type ”ls .” ?
Manipulating Files
mkdir: Build something new
Make a directory
> cd
> mkdir workshop
> ls workshop
What does this last command do?
Now, go into the new directory.
touch: Building another new thing
touch let’s you create new empty files easily
> cd workshop
> pwd
Output: ~/workshop
Make sure you are in the directory that you just created.
> ls
Verify that directory is empty
> touch this
> touch that
> touch other
Now what’s inside the directory?
Searching smart
Wildcards can be used in the command line.
> ls t*
Only list files starting with the letter t.
> ls *r
Only list files ending with the letter r.
Self-check
Only list files containing the letter “i”
Make another directory inside the workshop directory called “pets”
Put two new files in the directory called “cat” and “dog”
Check your work with a neighbor.
Did you accidentally put the cat and dog files in the
workshop directory instead of the pets directory?
rm: proceed with caution
(You know it’s serious when there’s a Star Wars gif.)
rm: proceed with caution
rm : remove file(s)
There is NO undo button or
command for rm
The most dangerous command
rm *
rm: Cleaning up mistakes
Go to the workshop directory. Create files “cat” and “dog” in this directory (unless
they are already there).
> pwd (should be “workshop”)
> touch cat
> touch dog
> ls (Verify that cat and dog are new files)
> rm cat
> ls (Verify that cat is now gone)
> rm dog
> ls (Verify that dog is now gone)
rmdir: remove directory
rmdir is rm for directories. Directories must be empty.
> cd
> cd workshop
> rmdir pets (will delete if directory is empty, otherwise keep going)
> cd pets
> rm *
> cd ..
> rmdir pets
> ls
pets directory should be gone
> and >> (not the prompt)
> ls > files.txt
Takes output of ls command and stores it in the file “files.txt”
> less files.txt
View the contents of “files.txt”
Use “q” to exit the view.
> ls >> files.txt
Append the output of the ls command to the file “files.txt”
> less files.txt
q to quit
cp: Copy and Paste in one command
You must indicate both the from location and the to
location
> cd
> cd workshop
> cp files.txt files2.txt
Take the file named files.txt and make a
copy of it called files2.txt
> ls
Verify that files2.txt was created.
How can I verify that files2.txt is in fact the same
as files.txt?
cp: Copy and Paste in one command
You must indicate both the from location and the to
location
> mkdir file_folder
> cp files2.txt file_folder/files3.txt
Take files2.txt, make a copy of it named
files3.txt and place it in the file_folder
directory.
> ls
> ls file_folder
mv: Moving files.
mv: move a file from one location to the other. Must specify both locations.
> cd
> cd workshop
> cd file_folder
> ls
> mv files3.txt ../files4.txt
> ls
> ls ..
> cd ..
> mv files4.txt file_folder
If no new filename is specified when moving to a new directory, then keep the original filename.
WARNING!
cp and mv will write over files that exist of the same name.
They behave just like rm. No mercy.
Self-check
Remove the file_folder directory and all its contents
Remove .txt files from the workshop directory in one step
Move “this” and “that” files to a new directory called “things”
Congratulations!!
Fun things to try
> whoami
> hostname
> clear
> reboot
> sudo reboot

More Related Content

ODP
Love Your Command Line
PPT
Linux commands
PDF
Basic linux commands
DOCX
Basic linux commands
PDF
Linux basic commands with examples
PDF
Linux intro 2 basic terminal
PDF
Basic linux commands for bioinformatics
PPT
Common linux ubuntu commands overview
Love Your Command Line
Linux commands
Basic linux commands
Basic linux commands
Linux basic commands with examples
Linux intro 2 basic terminal
Basic linux commands for bioinformatics
Common linux ubuntu commands overview

What's hot (20)

DOCX
Linux final exam
PPTX
Linux command for beginners
DOCX
Linux midterm quiz
PPTX
Basic unix commands
PDF
UNIX Command Cheat Sheets
PDF
11 unix osx_commands
PDF
Linux intro 1 definitions
PPTX
Piping into-php
PPTX
Pipes and filters
PPTX
Terminal commands ubuntu 2
PPT
Unix And C
PPT
Unix Basics
PPT
Basic command ppt
PDF
Terminalcommandsubuntu1 170123133631 (1)
PPTX
Linux Basic commands and VI Editor
PDF
PDF
Text mining on the command line - Introduction to linux for bioinformatics
PDF
Productivity tips - Introduction to linux for bioinformatics
PDF
Using the command line on macOS
Linux final exam
Linux command for beginners
Linux midterm quiz
Basic unix commands
UNIX Command Cheat Sheets
11 unix osx_commands
Linux intro 1 definitions
Piping into-php
Pipes and filters
Terminal commands ubuntu 2
Unix And C
Unix Basics
Basic command ppt
Terminalcommandsubuntu1 170123133631 (1)
Linux Basic commands and VI Editor
Text mining on the command line - Introduction to linux for bioinformatics
Productivity tips - Introduction to linux for bioinformatics
Using the command line on macOS
Ad

Similar to Code tacoma command_line (20)

PPTX
Command-Line 101
PPTX
Linux Command.pptx
PDF
Linux_Commands.pdf
PPTX
(Practical) linux 101
PPTX
various shell commands in unix operating system.pptx
PDF
Linux cheat sheet
PPTX
Linux Fundamentals
PPTX
Linux Commands.pptx
PDF
Linux Cheat Sheet.pdf
PPTX
Unix Linux Commands Presentation 2013
PPTX
2. UNIX OS System Architecture easy.pptx
PPTX
linux chapter 5.pptx lesson About introduction to linux
PDF
Course 102: Lecture 3: Basic Concepts And Commands
PPT
LinuxLabBasics.ppt
DOCX
Directories description
PDF
LinuxCommands (1).pdf
PPTX
Chapter 2 Linux File System and net.pptx
PDF
Unix command line concepts
PDF
Take Command of the Command Line
PDF
113-1_Perl_2_Linux_commands_for_beginner.pdf
Command-Line 101
Linux Command.pptx
Linux_Commands.pdf
(Practical) linux 101
various shell commands in unix operating system.pptx
Linux cheat sheet
Linux Fundamentals
Linux Commands.pptx
Linux Cheat Sheet.pdf
Unix Linux Commands Presentation 2013
2. UNIX OS System Architecture easy.pptx
linux chapter 5.pptx lesson About introduction to linux
Course 102: Lecture 3: Basic Concepts And Commands
LinuxLabBasics.ppt
Directories description
LinuxCommands (1).pdf
Chapter 2 Linux File System and net.pptx
Unix command line concepts
Take Command of the Command Line
113-1_Perl_2_Linux_commands_for_beginner.pdf
Ad

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Digital Strategies for Manufacturing Companies
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
L1 - Introduction to python Backend.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
ISO 45001 Occupational Health and Safety Management System
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
AI in Product Development-omnex systems
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo POS Development Services by CandidRoot Solutions
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Understanding Forklifts - TECH EHS Solution
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
2025 Textile ERP Trends: SAP, Odoo & Oracle
CHAPTER 2 - PM Management and IT Context
Digital Strategies for Manufacturing Companies
Design an Analysis of Algorithms I-SECS-1021-03
Design an Analysis of Algorithms II-SECS-1021-03
L1 - Introduction to python Backend.pptx
How Creative Agencies Leverage Project Management Software.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PTS Company Brochure 2025 (1).pdf.......
Wondershare Filmora 15 Crack With Activation Key [2025
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
ISO 45001 Occupational Health and Safety Management System
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
AI in Product Development-omnex systems
Internet Downloader Manager (IDM) Crack 6.42 Build 41

Code tacoma command_line

  • 1. Code Tacoma: Command Line Basics Andrea Urban September 8, 2018 Please sit next to someone with an operating system similar to yours.
  • 2. Agenda 1. Installation and Set up: 15 minutes 2. Introductions 3. Introduction to the Command Line 4. Basic Commands
  • 3. Installation and Setup Mac/unix/linux: Open terminal Windows: 3 options ● If you want to be a developer, but not interested in python (fastest install): Install Git Tools for Windows from the following URL: https://git-scm.com/download/win. When prompted in the installation wizard, select: "Use Git and optional Unix tools for the Windows Command Prompt". Open the git bash. ● If you want to learn python too: Install anaconda https://conda.io/docs/user-guide/install/windows.html. Don't do miniconda; do the full anaconda installer. Choose Python 3.6. Open the anaconda prompt and type ‘conda create -n main m2-base’. Say y to all queries. When Install is complete type “conda activate main” (To practice command line commands in future, you’ll need to type last command every time you reopen conda prompt. ● Big installation (not recommended): Install cygwin https://www.cygwin.com/ (a virtual unix machine for windows). I would not recommend this option because it's a really large program. However, if it's already installed, then you're ready. When you’re ready: Compare your screen to your neighbor’s. Check with another neighbor.
  • 4. Ground Rules If you have any trouble sounding condescending, find a UNIX user to show you how it's done. — Scott Adams, Dilbert Cartoonist ● Don’t act like a “UNIX user”. ● Mission: Learn UNIX tools and help others learn them too.
  • 5. Introductions Who am I? ● Andrea Urban ● Data scientist ● I mostly work in Python and SQL in Windows. In a past life, I used a Unix machine coding in Fortran. Who are you? ● Name ● Why are you interested in learning command line? ● Do you know any programming languages?
  • 6. CLI: Command Line Interface A text interface for interacting with a computer.
  • 7. GUI: Graphical User Interface Use mouse to interact with computer. Drag windows and files around.
  • 9. Why is it useful to learn the command line? Bulk actions - Ex: Delete all the jpg’s in a folder Connecting to remote servers Many remote servers only allow you to connect via a terminal. Remote server interface gui could be slow compared to terminal. Any other reasons?
  • 11. The prompt What do you see in your terminal? Puffy-Cloud:~ Andrea$ ● Puffy-Cloud = my computer’s name ● ~ = where I am located in my file system ● Andrea = my user name What your prompt may look like… > $ Any others?
  • 12. pwd: Where are we? > pwd What do you see? pwd = print working directory Tells you where you are in your file system.
  • 13. cd: Take me home. “cd” stands for “Change Directories” > cd Take me to my home directory ~ : refers to home directory (> cd ~ also takes user home) (Joke: There is no place like ~) What output do you see? > cd .. Take me up a directory What output do you see? How can you check if this worked?
  • 14. cd: Take me home. “cd” stands for “Change Directories” > cd > cd ../.. Take me up two directories Be sure to check your work. Self-check: How do I go home? How do I go up three directories?
  • 15. ls: Take a look around > cd First go back home. ls stands for “list” contents > ls List current directory’s contents What do you see? > ls .. Lists contents of directory above current directory Now what do you see?
  • 16. ls: Take a look around > cd > ls -l Show long format of contents of directory > man ls Show manual pages for the ls command. Use arrow keys to navigate. Useful for learning about new flags (-l is a flag) Use the man pages to find out what ls -l is showing you.
  • 17. Self-check What will you see if you try the following command? Take a guess before typing it in the terminal > ls ../.. How can I print out the file size in human-readable format, i.e., 3.5K instead of 3536 bytes? (Hint: take a look at the man page for ls)
  • 18. Hidden Files > cd > ls -a List ALL the contents of the current directory, including hidden files Hidden files generally start with a period “.” The hidden files: “.” and “..” represent the current and parent directory What do you expect to happen when you type ”ls .” ?
  • 20. mkdir: Build something new Make a directory > cd > mkdir workshop > ls workshop What does this last command do? Now, go into the new directory.
  • 21. touch: Building another new thing touch let’s you create new empty files easily > cd workshop > pwd Output: ~/workshop Make sure you are in the directory that you just created. > ls Verify that directory is empty > touch this > touch that > touch other Now what’s inside the directory?
  • 22. Searching smart Wildcards can be used in the command line. > ls t* Only list files starting with the letter t. > ls *r Only list files ending with the letter r.
  • 23. Self-check Only list files containing the letter “i” Make another directory inside the workshop directory called “pets” Put two new files in the directory called “cat” and “dog” Check your work with a neighbor.
  • 24. Did you accidentally put the cat and dog files in the workshop directory instead of the pets directory?
  • 25. rm: proceed with caution (You know it’s serious when there’s a Star Wars gif.)
  • 26. rm: proceed with caution rm : remove file(s) There is NO undo button or command for rm The most dangerous command rm *
  • 27. rm: Cleaning up mistakes Go to the workshop directory. Create files “cat” and “dog” in this directory (unless they are already there). > pwd (should be “workshop”) > touch cat > touch dog > ls (Verify that cat and dog are new files) > rm cat > ls (Verify that cat is now gone) > rm dog > ls (Verify that dog is now gone)
  • 28. rmdir: remove directory rmdir is rm for directories. Directories must be empty. > cd > cd workshop > rmdir pets (will delete if directory is empty, otherwise keep going) > cd pets > rm * > cd .. > rmdir pets > ls pets directory should be gone
  • 29. > and >> (not the prompt) > ls > files.txt Takes output of ls command and stores it in the file “files.txt” > less files.txt View the contents of “files.txt” Use “q” to exit the view. > ls >> files.txt Append the output of the ls command to the file “files.txt” > less files.txt q to quit
  • 30. cp: Copy and Paste in one command You must indicate both the from location and the to location > cd > cd workshop > cp files.txt files2.txt Take the file named files.txt and make a copy of it called files2.txt > ls Verify that files2.txt was created. How can I verify that files2.txt is in fact the same as files.txt?
  • 31. cp: Copy and Paste in one command You must indicate both the from location and the to location > mkdir file_folder > cp files2.txt file_folder/files3.txt Take files2.txt, make a copy of it named files3.txt and place it in the file_folder directory. > ls > ls file_folder
  • 32. mv: Moving files. mv: move a file from one location to the other. Must specify both locations. > cd > cd workshop > cd file_folder > ls > mv files3.txt ../files4.txt > ls > ls .. > cd .. > mv files4.txt file_folder If no new filename is specified when moving to a new directory, then keep the original filename.
  • 33. WARNING! cp and mv will write over files that exist of the same name. They behave just like rm. No mercy.
  • 34. Self-check Remove the file_folder directory and all its contents Remove .txt files from the workshop directory in one step Move “this” and “that” files to a new directory called “things”
  • 36. Fun things to try > whoami > hostname > clear > reboot > sudo reboot