π 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!