Linux Basics for Hackers - Cheat Sheet

A comprehensive Linux cheat sheet for hackers and security professionals, covering essential commands for navigation, permissions, networking, reconnaissance, system monitoring, and hacking tools — with runnable examples.
Linux is the go-to operating system for hackers and security professionals. Whether you're diving into ethical hacking, penetration testing, or cybersecurity research, mastering Linux is a must. This cheat sheet will help you get started with essential Linux commands and concepts every hacker should know — each with a practical example you can run yourself.
Why Linux for Hackers?
- Open-source & customizable — full control over the OS
- Powerful command-line tools — hundreds of built-in utilities
- Preferred by cybersecurity experts — Kali, Parrot, and BlackArch are built on it
- Widely used in penetration testing — from recon to post-exploitation
Basic Linux Commands
The bread and butter of navigating any Linux system.
# Print the current working directory
pwd
# List files and directories (add -l for details, -a for hidden files)
ls
ls -la
# Change directory
cd /var/log
cd .. # go up one level
cd ~ # go to your home directory
# Create a directory
mkdir myfolder
mkdir -p a/b/c # create nested directories
# Remove a file or directory (be careful! no undo)
rm file.txt
rm -rf myfolder
# Copy files and directories
cp file.txt copy.txt
cp -r folder backup_folder
# Move or rename files
mv file.txt new_name.txt
mv new_name.txt /tmp/
# Display file contents
cat /etc/passwd
# Open a file in an editor
nano notes.txt
vim notes.txt
# Show command history
history
history | tail -20
# Clear the terminal
clearUser & Permission Commands
Control who you are and who can touch your files.
# Show current user
whoami
# Display user ID and group ID
id
id root
# Execute a command as root
sudo apt update
sudo whoami # shows 'root' when run with sudo
# Change file permissions
# r=read(4) w=write(2) x=execute(1)
chmod 755 script.sh
chmod +x script.sh # make executable
chmod 600 secret.key # owner read/write only
# Change file owner
chown root:root file.txt
chown -R www-data:www-data /var/www
# Change user password
passwd
sudo passwd rootNetworking & Reconnaissance
Gather information about networks, hosts, and services.
# Show network interfaces and IP addresses
ifconfig
ip a
# Check network connectivity to a host
ping google.com
ping -c 4 8.8.8.8 # send exactly 4 packets
# Display active network connections and listening ports
netstat -tulpn
ss -tulpn # modern replacement for netstat
# Scan network ports
nmap -sV 192.168.1.1
nmap -sC -sV -p- 10.0.0.5
# Fetch data from a URL
curl https://example.com
curl -o page.html https://example.com
wget https://example.com/file.zip
# DNS lookup
dig example.com
nslookup example.comProcess & System Monitoring
See what's running on the box and keep an eye on resources.
# Show running processes
ps aux
ps aux | grep nginx
# Display system processes in real time
top
htop # interactive, nicer view
# Terminate a process (find PID first)
ps aux | grep nc
kill 1234 # kill by PID
kill -9 1234 # force kill
# Show disk space usage (human readable)
df -h
# Show memory usage in megabytes
free -m
# Check system uptime and load average
uptime
# Display system and kernel info
uname -a
# Show who is logged in
whoFile & Directory Navigation
Locate files and manipulate archives.
# Find files and directories by name
find / -name "config.yml"
find /home -type f -name "*.conf"
# Search text within files
grep "root" /etc/passwd
grep -r "password" /etc/
# Compress/extract tar archives
tar -czvf archive.tar.gz folder/ # compress
tar -xzvf archive.tar.gz # extract
# Create/extract ZIP files
zip -r files.zip folder/
unzip files.zip -d output/
# Find files quickly (uses a database)
sudo updatedb
locate sshd_configEssential Hacking Tools in Linux
Tools you'll reach for constantly during a pentest.
| Tool | Purpose | Example usage |
|---|---|---|
nmap | Network scanning | nmap -sS 192.168.1.0/24 |
Metasploit | Exploitation framework | msfconsole |
Wireshark | Packet analysis | wireshark |
Hydra | Brute-force attacks | hydra -l admin -P pass.txt ssh://192.168.1.1 |
John the Ripper | Password cracking | john hash.txt |
sqlmap | SQL injection testing | sqlmap -u "http://target/page?id=1" |
aircrack-ng | Wi-Fi penetration testing | aircrack-ng -w wordlist.txt capture.cap |
Final Thoughts
This cheat sheet gives you a solid foundation in Linux, essential for cybersecurity and ethical hacking. Keep practicing these commands, explore more tools, and stay updated with new techniques.
Try it yourself: spin up a Kali Linux VM (or any distro) and run through each example above. The best way to learn Linux is by breaking things — in a sandbox, of course.
Happy Hacking!

Written by Robin te Hofstee
Technology enthusiast with a deep love for programming. Sharing practical guides on React, Next.js, Linux and self-hosting.
Related Posts
Securing a Next.js Application in Production
Securing a Next.js app in production means protecting the client bundle, the server, and the data flow. This post shows how to lock down Content‑Secur
How Git Works
Git is a distributed version control system that allows multiple people to collaborate on a project while maintaining a complete history of all change
How to Check Disk Usage and Find Large Files on Linux
After setting up a new Linux server, you’ll want to know how to check what’s taking up space. Disk space is often the weakest link in system stability


