0% found this document useful (0 votes)
9 views2 pages

Basic Shell Commands - Lesson 5

This document provides a quick reference guide for basic shell commands, including navigation, file inspection, editing, and file management commands. It also explains the use of wildcards and additional commands like echo and chmod. Related resources for further learning are also included.

Uploaded by

sam perera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Basic Shell Commands - Lesson 5

This document provides a quick reference guide for basic shell commands, including navigation, file inspection, editing, and file management commands. It also explains the use of wildcards and additional commands like echo and chmod. Related resources for further learning are also included.

Uploaded by

sam perera
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Quick reference: Basic shell commands

Note: Bracketed items (<>) denote where to place your input. Do not include the
brackets in your command.

Navigate directories

Command Use Notes


cd <path/to/directory> changes current directory to path/to/directory . - the curren
.. - one level
~ - your home
pwd prints path of the working (current) directory
ls <directory> lists files in directory -lh prints hu
ls list files in current directory -a prints hidd
mkdir <directory> creates a directory
rmdir <directory> removes a directory (must be empty)

Inspect files

Command Use
cat <file> prints contents of file
less <file> views contents of file (similar to vim, but without edit cap
head <file> prints the first ten lines of file
tail <file> prints the last ten lines of file
grep <phrase> <file> grabs and prints every instance of phrase in file

Edit files

Command Use Note


nano <file> opens or creates file in the nano text editor cheat
vim <file> or vi <file> opens or creates file in the vim text editor cheat

Copy, move, and remove files

Command Use
cp <file1> <file2> copies file1 to file2
mv <file1> <file2> moves or renames file1 to file2
rm <file1> removes file1
Command Use
scp <file> <destination> moves files between machines. See how to transfer files to/f

Wildcards

Wildcard Use Notes


? matching any character Example: rm ?.txt removes [Link] an
* matching any characters of any length Example: rm *.txt removes all files w

Read more about wildcards.

Other commands

Commmand Use Notes


echo <$var> prints the value of $var Example: echo $PWD returns t
chmod +x adds executable permissions to a file

Related pages
Browse these resources for learning basic shell commands and the command line.

• Cornell Virtual Workshop: An Introduction to Linux


• Software Carpentry Unix Shell
• Ubuntu tutorial: The Linux command line for beginners
• Unix/Linux Command Reference cheat sheet

You might also like