📝 Basic Linux Commands
These commands are your toolbox for controlling everything from files to folders right from the terminal. Linux is built around commands, not clicks. Each command is like a mini sentence that tells the OS what to do — create something, move it, delete it, or view it.
ls — List Files and Folders
Shows the contents of the current directory.
Desktop Documents Downloads Pictures
Common options:
- ls -l → long listing (shows permissions, size, date)
- ls -a → includes hidden files (files starting with a dot .)
- ls -lh → human-readable file sizes (e.g., KB, MB)
Like opening a drawer to see everything inside neatly.
pwd — Print Working Directory
Displays where you are right now.
/home/master/Documents
Like checking your current address on a map.
cd — Change Directory
Moves you between folders.
Go one folder up:
Go to your home directory:
Like walking between rooms in a house.
mkdir — Make Directory
Creates a new folder.
Create multiple folders at once:
Like creating a new shelf to store items.
rmdir — Remove Directory
Deletes empty folders only.
To remove a folder with files inside, you'll need rm -r (explained below).
rm — Remove Files or Folders
Deletes files (and folders if used with options).
Delete a file:
Delete a folder and its contents:
Force delete (no confirmation):
⚠️ Be careful! rm -rf / will wipe your entire system — never do that!
Like throwing files into a shredder — once gone, they're gone.
cp — Copy Files or Folders
Copies files from one place to another.
Copy folders (add -r for recursive):
Like photocopying a document and placing it somewhere else.
mv — Move or Rename Files
Moves or renames files and folders.
Move file:
Rename file:
Like moving an item to another shelf — or just changing its label.
cat — View File Content
Displays the content of a text file right in the terminal.
You can also combine multiple files:
Like opening a notebook to quickly read what's inside.
less / more — View Large Files Page by Page
When files are too long for one screen:
- Press Space → to go down
- Press q → to quit
Like scrolling through a long e-book, one page at a time.
head & tail — View Beginning or End of a File
Show first 10 lines:
Show last 10 lines:
For real-time updates (like logs):
head → first page of a diary. tail → last page of the diary.
touch — Create an Empty File
Quickly create a blank file:
Or update its modification time:
Like putting a new empty sheet of paper on your desk.
echo — Print a Message or Save Text to a File
Print text:
Save text into a file:
Like writing a quick sticky note.
man — Manual Pages
Shows help and usage details for any command.
Use q to quit the manual.
Like asking Linux, "Hey, what exactly does this command do?"
history — Shows Previous Commands
Lists all the commands you've used in this session.
You can reuse one by number:
Like scrolling through your browser history.
Real-Life Pro Tip
You can chain commands using &&:
This means: Create a folder, Move into it, Create a file — all in one line!
Your Linux Command Toolkit
With these, you can manage almost everything from the terminal — files, folders, and navigation.
Real-life analogy
Think of these basic commands like the essential tools in a Swiss Army knife:
📁 ls → The magnifying glass to see what's inside
📍 pwd → The compass to know where you are
🚶 cd → The walking tool to move around
🏗️ mkdir → The hammer to build new structures
✂️ rm → The scissors to cut and remove
📋 cp → The photocopier to duplicate
🚚 mv → The moving truck to relocate
📖 cat → The quick-read viewer
Each tool is simple on its own, but together they give you incredible control over your digital workspace!