Simple Intro to the Linux Command Line (bash)
This is a minimal, practical cheat sheet for everyday tasks on Linux (bash).
Most of this works the same in other shells too.
0) Open a terminal
- Usually: Applications → Terminal
- Common shortcut: Ctrl + Alt + T (varies by distro)
1) Core ideas
Your location (current folder)
- Show current folder:
pwd - List files:
ls
Paths
.means “this folder”..means “parent folder”/is the path separator
Examples:
cd .
cd ..
cd /home/yourname/Downloads
Autocomplete + history
- Press Tab to autocomplete.
- Use ↑ / ↓ for command history.
2) Navigate folders
- Change folder:
cd <path>
Examples:
cd Documents
cd ..
cd ~
~is your home folder.
3) Create, copy, move, delete
Create a folder
mkdir <foldername>
Create an empty file
touch <filename>
Copy
cp <source> <destination>
Move / rename
mv <source> <destination>
If you do not know the
Delete (be careful)
- Delete a file:
rm <filename> - Delete a folder and everything inside:
rm -r <foldername>
Tip: If you are unsure, run
lsfirst and double-check the path.
4) View file contents
- Print a text file:
cat <filename> - View long output one screen at a time:
less <filename>(Press
qto quit.)
5) Search (basic)
- Find files/folders by name:
find . -name "*partialname*" - Search inside files for text:
grep -R "text" .
Quick safety rules
- If you do not know what a command does, do not run it :)
- Be extra careful with
rm(especiallyrm -r). - Quote paths with spaces:
cd "My Folder"
A tiny practice routine (2 minutes)
mkdir cli-practice
cd cli-practice
touch notes.txt
ls
echo "hello" >> notes.txt
cat notes.txt
cd ..
rm -r cli-practice