Chapter 4: Basic Commands
Basic Commands in Bash — the absolute foundation.
Think of these as the “alphabet” of the terminal. Once you know these 15–20 commands really well, 80% of your daily terminal work becomes easy and fast. We’ll go slow, explain like friends in Hyderabad, show exact examples, what they do, common mistakes, and useful options.
Open your terminal now (Ctrl + Alt + T on Ubuntu, Terminal on macOS, Git Bash on Windows).
Important teacher tip first:
- Press Tab key after typing part of a command or folder name → Bash auto-completes (magic!)
- Press ↑ (up arrow) → see previous commands
- Type history → see list of past commands
- Wrong command? Just press Ctrl + C to stop and try again
Navigation & Location Commands (The Most Used Ones)
-
pwd → Print Working Directory (Where am I right now?)
Bash0123456pwdExample output: /home/webliance or /home/webliance/bash_class
→ Always know your location before doing anything!
-
ls → List files and folders
Bash0123456ls→ Shows normal files/folders
Better versions (use these daily!):
Bash0123456789ls -l # long format: shows permissions, size, datels -la # shows hidden files too (files starting with .)ls -lah # human-readable sizes (KB, MB instead of bytes)ls --color=auto # colors folders blue, executables green (most terminals do this auto)Example:
text012345678910webliance@ubuntu:~$ ls -ladrwxr-xr-x 5 webliance webliance 4096 Feb 25 13:10 .drwxr-xr-x 20 webliance webliance 4096 Feb 25 12:00 ..-rw-r--r-- 1 webliance webliance 220 Feb 25 13:05 hello.shdrwxrwxr-x 2 webliance webliance 4096 Feb 25 13:15 my_folder -
cd → Change Directory (Go somewhere else)
Bash01234567891011cd my_folder # go inside "my_folder"cd .. # go one level up (parent folder)cd ~ # go to your home (same as just typing cd)cd / # go to root (top level of whole system)cd ~/Downloads # go to Downloads in your homecd - # go back to previous folder you were inPro tip: cd with no argument = go home
Bash01234567cdpwd # → /home/webliance
File Creation & Viewing
-
touch → Create empty file or update timestamp
Bash01234567touch notes.txttouch report_2026.txt backup.sh -
cat → Show content of file (concatenate)
Bash01234567cat notes.txtcat file1.txt file2.txt # shows both one after anotherGood for small files. For big files use less or more (next).
-
echo → Print something on screen (very useful in scripts too)
Bash012345678echo "Hello Hyderabad!"echo "Today is $(date)" # runs date command insideecho $HOME # shows your home path -
mkdir → Make Directory
Bash01234567mkdir projectmkdir -p parent/child/grandchild # creates all folders at once -
rmdir → Remove empty directory
Bash0123456rmdir empty_folder
Copy, Move, Rename, Delete
-
cp → Copy files/folders
Bash012345678cp old.txt new.txt # copy filecp -r folder1 folder2 # copy folder + everything inside (-r = recursive)cp *.jpg ~/Pictures/ # copy all jpg files to Pictures -
mv → Move or Rename
Bash012345678mv oldname.txt newname.txt # renamemv file.txt ~/Documents/ # move to another foldermv -i file.txt backup/ # -i asks before overwrite (safe!) -
rm → Remove (delete) — be careful!
Bash0123456789rm file.txt # delete filerm -r folder # delete folder + contentsrm -rf folder # force delete, no questions (dangerous!)rm -i *.tmp # asks before deleting each (.tmp files)Teacher warning: No recycle bin in terminal — deleted = gone forever. Use -i when learning!
Help & Information
- man → Manual (help page) for any command
Bash01234567man lsman cp
→ Press q to quit, / to search inside
- –help → Quick help
Bash0123456ls --help
- whatis / which
Bash01234567whatis ls # short descriptionwhich ls # shows where the command lives (/usr/bin/ls usually)
Quick Useful Extras (Beginner Friendly)
- clear → Clear the screen
Bash0123456clear
- date → Show current date/time
Bash01234567datedate +"%Y-%m-%d" # nice format: 2026-02-25
- whoami → Who am I logged in as?
Bash0123456whoami # → webliance
- df -h → Disk free space (human readable)
Bash0123456df -h
- free -h → Memory (RAM) usage
Bash0123456free -h
- history → See past commands
Bash0123456history | tail -10 # last 10 commands
Practice Session Right Now (5 Minutes!)
Create a playground:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
cd ~ mkdir bash_basic_practice cd bash_basic_practice touch file1.txt file2.txt mkdir photos echo "This is test file" > file1.txt cat file1.txt ls -la cp file1.txt backup_copy.txt mv backup_copy.txt photos/ ls photos/ rm file2.txt cd .. pwd |
See? You just used 10+ commands!
Quick Reference Table (Copy to your notes!)
| Command | What it does | Best example / Option |
|---|---|---|
| pwd | Show current path | pwd |
| ls | List contents | ls -la or ls -lah |
| cd | Change folder | cd .. , cd ~ , cd folder |
| mkdir | Create folder | mkdir -p deep/path |
| touch | Create empty file | touch newfile.txt |
| cat | View file content | cat file.txt |
| echo | Print text | echo “Hi” > file.txt (write to file) |
| cp | Copy | cp -r src dest |
| mv | Move / Rename | mv old new |
| rm | Delete | rm -i file (safe) |
| man | Read manual | man cp |
| date | Show date/time | date +%F |
Master these → next we’ll do pipes (), grep, redirection (> , >>), and small scripts.
Any command confusing? Type it wrong and got error? Tell me — we’ll fix together! Or say: “Teacher, explain ls options more” or “give practice exercises”
You’re doing great — keep typing every day! 🐧🚀 From Hyderabad with love! 😄
