Chapter 5: Bash Commands
Bash commands are the words/phrases you type in the terminal that Bash understands and executes. Almost everything you do in Bash is running one (or many) of these commands.
There are hundreds of commands, but today we’ll focus on the 30–35 most important ones for beginners to intermediate level — the ones you’ll use 90% of the time in real life (Hyderabad developer, server work, automation, etc.).
We’ll group them nicely, explain what, why, how, common options, examples, and little warnings from your friendly teacher.
Group 1: Navigation & Orientation (You use these 100 times a day)
- pwd — Print Working Directory Where am I right now?
Bash0123456pwd
→ /home/webliance/projects/myapp
- ls — List Show what’s in current folder
Bash01234567891011ls # simple listls -l # long format (permissions, size, date)ls -la # show hidden files (start with .)ls -lah # human-readable sizes (KB, MB)ls -l --color=auto # colored output (most terminals do auto)ls *.jpg # only jpg files
- cd — Change Directory Move around
Bash01234567891011cd myfolder # go insidecd .. # one level upcd ~ # or just cd → go homecd /etc # absolute pathcd ~/Downloads # home + relativecd - # back to previous location
Group 2: Creating & Viewing Stuff
- mkdir — Make Directory
Bash01234567mkdir new_projectmkdir -p parent/child/grand # create full path if missing
- touch — Create empty file or update timestamp
Bash01234567touch notes.txt report.mdtouch file{1..5}.txt # creates file1.txt to file5.txt
- echo — Print text (also writes to files)
Bash0123456789echo "Hello Hyderabad!"echo "Line 1" > file.txt # overwriteecho "Line 2" >> file.txt # appendecho $PATH # show variable
- cat — Concatenate / show file content
Bash012345678cat readme.mdcat file1.txt file2.txt > combined.txtcat > newfile.txt # type until Ctrl+D
- less / more — View large files page by page
Bash01234567less long_log.txt # arrow keys, / to search, q to quitmore access.log # simpler version
Group 3: Copy, Move, Rename, Delete (Be careful!)
-
cp — Copy
Bash0123456789cp source.txt dest.txtcp -r folder1 backup_folder # recursive for folderscp *.png ~/Pictures/cp -i file.txt dest/ # ask before overwrite -
mv — Move / Rename
Bash012345678mv oldname.txt newname.txt # renamemv file.txt ../other_folder/mv -i important.txt backup/ # safe (asks) -
rm — Remove (no recycle bin — gone forever!)
Bash0123456789rm temp.txtrm -r old_project/ # delete folder + contentsrm -rf node_modules/ # force, dangerous!rm -i *.tmp # ask for each fileTeacher golden rule: Always use -i when learning. Never rm -rf / (it can destroy your system!)
-
rmdir — Remove empty directory
Bash0123456rmdir empty_folder
Group 4: Finding & Searching
- find — Search for files
Bash012345678find . -name "*.log" # in current folderfind /home -type f -size +100M # big files >100MBfind . -mtime -7 # modified last 7 days
- grep — Search inside text
Bash0123456789grep "error" server.loggrep -i "todo" *.md # case insensitivegrep -r "function" . # recursive in all filesgrep -n "bug" app.js # show line numbers
- which / whereis / type
Bash01234567which python # where is the command located?type ls # is it alias, builtin, or external?
Group 5: System Info & Help
- date
Bash01234567datedate +"%Y-%m-%d %H:%M:%S" # custom format
- whoami / id
Bash01234567whoami # your usernameid -un # same
- df -h — Disk free (human readable)
Bash0123456df -h
- du -sh — Disk usage
Bash01234567du -sh ~/Downloads # how big is Downloads?du -sh * | sort -h # sort folders by size
- free -h — Memory usage
Bash0123456free -h
- top / htop — Live processes (htop is nicer if installed)
Bash0123456top
- man — Manual (best help!)
Bash01234567man lsman cp # press q to quit
- –help — Quick help
Bash0123456ls --help
Group 6: Power User Basics (You’ll love these soon)
- history — See past commands
Bash01234567history | tail -20!123 # run command number 123 from history
- clear — Clear screen
Bash01234567clearCtrl + L # same (shortcut)
- alias — Create shortcuts
Bash012345678alias ll='ls -la'alias update='sudo apt update && sudo apt upgrade -y'# Put in ~/.bashrc to keep forever
- uname -a — System info
Bash0123456uname -a
- ps aux — List processes
Bash0123456ps aux | grep chrome
- kill — Stop process
Bash01234567kill 1234 # PID from pskill -9 5678 # force kill
- sudo — Run as superuser
Bash0123456sudo apt update
Quick Cheat Table (Save this!)
| Category | Command | Most Useful Form | What it does briefly |
|---|---|---|---|
| Where am I? | pwd | pwd | Current path |
| List | ls | ls -lah | Files + details + hidden + sizes |
| Move | cd | cd .. / cd ~ | Navigate |
| Create folder | mkdir | mkdir -p path/to/create | Make folders |
| Create file | touch | touch file.txt | Empty file |
| View file | cat / less | less bigfile.log | Read content |
| Copy | cp | cp -r src dest | Copy file/folder |
| Move/Rename | mv | mv old new | Rename or move |
| Delete | rm | rm -i file / rm -r dir | Delete (careful!) |
| Search file | find | find . -name “*.py” | Find by name/type |
| Search text | grep | grep -r “error” . | Find text in files |
| Disk | df -h / du -sh | du -sh * |
sort -h |
| Help | man / –help | man grep | Read documentation |
Practice right now — open terminal:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
mkdir bash_commands_practice cd bash_commands_practice touch file1.txt file2.txt echo "Hello from Hyderabad" > greeting.txt ls -la cat greeting.txt cp greeting.txt backup.txt mv backup.txt renamed.txt grep "Hyderabad" *.txt pwd cd .. |
Tell me what output you got or if any command gave error — we’ll debug together!
Next class? Say: “Teacher, explain pipes and redirection” “More on grep and find” “Show 10 real mini-scripts using these commands” “File permissions (chmod, chown)”
You’re getting faster every day — keep practicing! 🐧💪 From sunny Hyderabad! 😊
