Skip to content
Robin te Hofstee — Personal Blog
➜~neofetch

robin@blog

Name
Robin te Hofstee
Role
Full-stack developer, sysadmin & technical writer
Focus
homelab · Linux · self-hosting · Next.js
Posts
60 · latest Nov 17, 2026
Host
blog.robintehofstee.com
Links
github · rss · portfolio
➜curlblog.robintehofstee.com
➜~cat/blog/linux-basics-for-hackers-cheatsheet.mdx
←cd ~

Linux Basics for Hackers - Cheat Sheet

Aug 12, 20264 minlinuxsecurityhackingcybersecuritycheatsheet

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.

bash
# 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
clear

User & Permission Commands#

Control who you are and who can touch your files.

bash
# 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 root

Networking & Reconnaissance#

Gather information about networks, hosts, and services.

bash
# 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.com

Process & System Monitoring#

See what's running on the box and keep an eye on resources.

bash
# 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
who

File & Directory Navigation#

Locate files and manipulate archives.

bash
# 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_config

Essential Hacking Tools in Linux#

Tools you'll reach for constantly during a pentest.

ToolPurposeExample usage
nmapNetwork scanningnmap -sS 192.168.1.0/24
MetasploitExploitation frameworkmsfconsole
WiresharkPacket analysiswireshark
HydraBrute-force attackshydra -l admin -P pass.txt ssh://192.168.1.1
John the RipperPassword crackingjohn hash.txt
sqlmapSQL injection testingsqlmap -u "http://target/page?id=1"
aircrack-ngWi-Fi penetration testingaircrack-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!