๐ Story Hook
When I first saw a Linux terminal, I thought, "this is what hackers in movies use." A black screen, white text, nothing makes sense.
Now, I open the terminal 200 times a day. And every time, it's more convenient than using a mouse. Seriously.
The terminal is a direct conversation with your computer. No need to click "Open โ Folder โ Documents โ New Folder". One command, and you're done.
In this lesson, we'll learn 10 commands. After that, the terminal will become your best friend.
๐ฏ Command #1: pwd โ "where am I"
Open the terminal. Type:
pwd
Response:
/home/kali
pwd = "Print Working Directory". Shows your current folder.
This is your home folder. Similar to "C:\Users\Your Name" in Windows.
๐ฏ Command #2: ls โ "what's around me"
ls
Will show you the files and folders in your current directory:
Desktop Documents Downloads Music Pictures Public Templates Videos
Options (always after the command, separated by a space):
ls -l # detailed (size, date, permissions)
ls -a # including hidden files (starting with .)
ls -la # both at once
ls -lh # size in human-readable format (KB / MB / GB)
Try: ls -la. You'll see many more files.
๐ฏ Command #3: cd โ "move to another folder"
cd Documents
You've entered the Documents folder. Check:
pwd
# /home/kali/Documents
Special symbols:
cd .. # one level up (parent folder)
cd ~ # home (=/home/kali)
cd / # system root
cd - # previous folder (like Back)
๐ก Tab Life Hack: start typing a folder name โ press Tab โ the terminal will auto-complete. This will save you hours over your career.
๐ฏ Command #4: cat โ "show file contents"
cat /etc/hostname
Will show you "kali" (your computer's name).
cat /etc/os-release
Will show you system info (Kali version, ID, etc.).
For long files:
less /etc/passwd # scroll with arrows, exit with q
head -10 file.txt # first 10 lines
tail -10 file.txt # last 10 lines
tail -f /var/log/auth.log # follow changes in real-time
๐ฏ Command #5: grep โ "find text in a file"
This is a super-important command for hackers. Searches for lines containing specific text.
grep "kali" /etc/passwd
Will show you lines in /etc/passwd containing "kali".
Useful options:
grep -i "PASSWORD" config.txt # case-insensitive
grep -r "secret" /var/www/ # recursive search
grep -n "error" log.txt # with line numbers
grep -v "INFO" log.txt # exclude matches
Real-life example: you've hacked a site, downloaded base.tar.gz, and need to find the database password:
grep -ri "DB_PASSWORD\|db_pass\|database.*password" extracted_files/
๐ฏ Command #6: find โ "find files"
find / -name "passwd" 2>/dev/null
Will find all files named "passwd" on the entire system. 2>/dev/null ignores access errors.
Useful patterns:
find . -name "*.conf" # all .conf files in the current and subfolders
find /home -type f -size +10M # files larger than 10MB in /home
find / -perm -4000 2>/dev/null # all SUID files (important for privilege escalation!)
find / -mtime -1 # files modified in the last 24 hours
๐ฏ Command #7: mkdir / rm / mv / cp
mkdir test_folder # create a folder
mkdir -p path/to/deep/dir # create nested folders
cp file.txt backup.txt # copy a file
cp -r folder1 folder2 # copy a folder recursively
mv old.txt new.txt # rename (or move)
mv file.txt /tmp/ # move to /tmp
rm file.txt # delete a file
rm -rf folder/ # delete a folder with all contents (BE CAREFUL!)
โ ๏ธ rm -rf / will delete EVERYTHING. Never run this command. And don't trust code from unverified sources that contains it.
๐ฏ Command #8: chmod โ "change permissions"
More details in Lesson 2.3, but the basics:
chmod +x script.sh # make executable
chmod 755 file # rwx for owner, r-x for others
chmod 644 config.txt # rw for owner, r for others
๐ฏ Command #9: pipes (|) and redirects (>, >>)
This is Unix magic. Connects multiple commands:
# Pipe (|): output of one command โ input of another
ls -la | grep "kali" # ls + search for lines with "kali"
cat log.txt | grep "ERROR" | head -10 # last 10 errors
# Redirect (>): save output to a file
ls -la > files.txt # overwrite
ls -la >> files.txt # append
# Stderr (2>): redirect errors
find / -name "secret" 2>/dev/null # ignore access errors
Real-life example: find all .php files containing "mysql_query":
find /var/www -name "*.php" | xargs grep -l "mysql_query" 2>/dev/null
๐ฏ Command #10: sudo โ "run as admin"
sudo apt update # update package list
sudo apt install nmap # install nmap
sudo -i # become root (exit with exit)
sudo = "Super User DO". Asks for your password (your regular one, for kali). After entering the password, the command runs with root privileges.
๐ก Life Hack: sudo remembers your password for ~15 minutes. Enter it once, and subsequent sudo commands will run without asking for a password.
๐ Final Exercise
Run the following commands in the terminal, in order:
cd ~ โ go home
mkdir hacking_practice โ create a folder
cd hacking_practice โ enter the folder
echo "Hello hacker world" > greet.txt โ create a file
cat greet.txt โ check the contents
ls -la โ see what's in the folder
grep "hacker" greet.txt โ find the word
cp greet.txt greet_backup.txt โ make a copy
ls โ two files should be there
rm greet_backup.txt โ delete the copy
cd .. โ exit the folder
If all 11 commands succeed โ you've mastered the basics of the terminal. This is enough for 95% of a penetration tester's work.
๐ค Vibe-task: ask Claude
Open Claude and ask:
I've just learned 10 basic Linux commands:
pwd, ls, cd, cat, grep, find, mkdir/rm/mv/cp, chmod, pipes, sudo.
Give me 5 practical tasks with a difficulty level from easy to medium
that I can complete right now in my Kali Linux to reinforce my skills.
Each task โ 1 sentence with what to do + expected result.
Complete these 5 tasks. If you get stuck โ ask Claude again.
๐ก Cheat Sheet (print it)
| Command | What it does | Example |
pwd | Shows current folder | pwd |
ls | Shows files and folders | ls -la |
cd | Changes folder | cd Documents |
cat | Shows file contents | cat file.txt |
grep | Finds text in a file | grep "error" log |
find | Finds files | find / -name "*.conf" |
mkdir | Creates a folder | mkdir test |
cp / mv / rm | Copies / moves / deletes | cp a b |
chmod | Changes permissions | chmod +x script |
| | Pipes output | ls | grep "txt" |
sudo | Runs as admin | sudo apt update |
๐ฌ What's Next
In Lesson 2.3, we'll cover permissions and root. What "root" means, where passwords are stored in Linux, and what chmod 755 exactly means. This is the foundation for Module 5, "Web Vulnerabilities", where we need to understand how servers store data.