Kali Linux is the operating system of choice for ethical hackers. Almost every hacking tool runs on Linux. This lesson gets you comfortable with the command line — your most powerful interface as a security professional.
Why Linux?
Linux is open-source, highly customizable, and runs on most servers in the world. Kali Linux comes pre-loaded with 600+ security tools. As a hacker, you’ll spend most of your time in the terminal — understanding Linux is not optional.
Essential Linux Commands
Navigation & Files:
- pwd — Print working directory (where am I?)
- ls -la — List all files including hidden ones with permissions
- cd /path/to/dir — Change directory
- cp file.txt /destination/ — Copy a file
- mv file.txt newname.txt — Move or rename a file
- rm -rf folder/ — Delete folder and contents (use carefully!)
- find / -name ‘passwords.txt’ — Search the entire filesystem
- cat file.txt — Display file contents
- grep ‘password’ file.txt — Search for text in a file
- chmod 755 script.sh — Change file permissions
- sudo command — Run as superuser (administrator)
Networking Commands in Linux
- ifconfig / ip a — Show network interfaces and IP addresses
- netstat -tulnp — Show open ports and listening services
- curl https://example.com — Make an HTTP request from terminal
- wget https://file.com/tool.zip — Download a file
- ssh user@192.168.1.1 — Connect to a remote server securely
- nmap 192.168.1.1 — Quick port scan (we’ll cover this in depth later)
File Permissions Explained
In Linux, every file has three permission types: Read (r=4), Write (w=2), Execute (x=1). Permissions are set for Owner, Group, and Others. Example: chmod 755 means owner can read/write/execute (7), group can read/execute (5), others can read/execute (5).
Basic Bash Scripting
A bash script automates repetitive tasks. Create a file called scan.sh:
- #!/bin/bash (shebang — tells system to use bash)
- echo ‘Starting scan…’
- for ip in 192.168.1.{1..254}; do ping -c 1 -W 1 $ip &> /dev/null && echo “$ip is alive”; done
- Make it executable: chmod +x scan.sh then run: ./scan.sh
Practical Exercise
Practical Exercise: Linux Command Drill
- Step 1: Boot into Kali Linux (VM or live USB). Open a terminal.
- Step 2: Navigate to /etc/ and read the passwd file: cat /etc/passwd
- Step 3: Create a directory called ‘hacking_practice’, navigate into it, and create 3 text files.
- Step 4: Use grep to search for the word ‘root’ inside /etc/passwd.
- Step 5: Write a bash script that pings 5 different IP addresses and reports which ones are alive.
- Step 6: Use chmod to set different permission levels on your script and test the difference.
Tools Used in This Lesson
|
Tool |
Purpose |
Free / Paid |
|
Kali Linux |
Primary hacking OS |
Free |
|
VirtualBox |
Run Kali as a VM |
Free |
|
Bash Terminal |
Command-line interface |
Free (built-in) |
|
nano / vim |
Text editors in Linux |
Free (built-in) |
Â
|
Lesson Outcome |
|
Students can navigate the Linux filesystem, use essential commands, manage file permissions, and write basic Bash automation scripts. |