Linux is the operating system of hackers. Whether you're using Kali Linux, Ubuntu, or Parrot OS, mastering these commands will make you significantly more effective as a security professional.
pwd # Print current working directory
ls -la # List files with permissions and hidden files
ls -lah # Same but human-readable file sizes
cd /path # Change directory
cd .. # Go up one directory
cd ~ # Go to home directory
cd - # Go to previous directory
# Find files
find / -name "*.txt" 2>/dev/null
find / -perm -4000 2>/dev/null # Find SUID files (privilege escalation)
find /home -name "*.conf" # Find config files
locate filename # Fast search (uses database)
cat file.txt # Display file contents
head -n 20 file.txt # First 20 lines
tail -n 20 file.txt # Last 20 lines
tail -f /var/log/auth.log # Watch file in real-time
less file.txt # Page through file
# Copy, move, delete
cp source dest # Copy
cp -r dir/ /backup/ # Copy directory recursively
mv file.txt /tmp/ # Move/rename
rm file.txt # Delete file
rm -rf directory/ # Delete directory (CAREFUL!)
# Text manipulation
grep "pattern" file.txt # Search for pattern
grep -r "password" /var/www/ # Recursive search
grep -i "error" log.txt # Case insensitive
cat /etc/passwd | grep -v "nologin" # Filter out nologin accounts
awk -F: '{print $1}' /etc/passwd # Extract usernames
cut -d: -f1,3 /etc/passwd # Cut specific fields
# IP and interfaces
ip a # Show all interfaces and IP addresses
ip route # Show routing table
ifconfig # Traditional interface info
# Connectivity
ping 8.8.8.8 # Test connectivity
ping -c 4 google.com # Send 4 pings only
traceroute google.com # Trace route to host
mtr google.com # Combined ping + traceroute
# DNS
nslookup example.com # Basic DNS lookup
dig example.com # Detailed DNS info
dig example.com MX # Mail server records
dig @8.8.8.8 example.com # Use specific DNS server
host example.com # Simple DNS lookup
# Open connections
netstat -tulpn # Show listening ports with PID
ss -tulpn # Modern alternative to netstat
lsof -i :80 # Who is using port 80?
lsof -i :443
ps aux # All running processes
ps aux | grep apache # Find specific process
top # Real-time process monitor
htop # Better top (colored)
kill 1234 # Kill process by PID
kill -9 1234 # Force kill
killall nginx # Kill by name
pkill -f "python script.py" # Kill by command pattern
# Background jobs
command & # Run in background
jobs # List background jobs
fg 1 # Bring job 1 to foreground
bg 1 # Continue job 1 in background
nohup command & # Run immune to hangup
whoami # Current user
id # User ID, group memberships
sudo command # Run as root
sudo -l # List sudo permissions
su username # Switch user
# File permissions
chmod 755 script.sh # rwxr-xr-x
chmod +x script.sh # Add execute permission
chmod 600 private_key.pem # rw------- (SSH key)
chown user:group file.txt # Change owner
chown -R www-data /var/www/ # Recursive ownership change
# SUID/SGID (important for privilege escalation)
find / -perm -u=s 2>/dev/null # Find SUID files
find / -perm -g=s 2>/dev/null # Find SGID files
# Service management (systemd)
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl status apache2
sudo systemctl enable apache2 # Start on boot
# Traditional init.d
sudo service ssh start
sudo service ssh status
# Check all listening ports
sudo nmap -sS localhost
sudo netstat -tlnp
# tar archives
tar -czf archive.tar.gz directory/ # Create compressed archive
tar -xzf archive.tar.gz # Extract archive
tar -tzf archive.tar.gz # List contents
# zip
zip -r archive.zip directory/
unzip archive.zip -d /destination/
# Connect to remote host
ssh user@192.168.1.1
ssh -p 2222 user@host.com # Custom port
ssh -i key.pem user@host.com # Using private key
# Copy files securely
scp file.txt user@192.168.1.1:/tmp/ # Upload
scp user@192.168.1.1:/tmp/file.txt . # Download
scp -r directory/ user@host:/backup/ # Copy directory
# SSH tunneling (port forwarding)
ssh -L 8080:localhost:80 user@server # Local port forward
ssh -R 4444:localhost:4444 user@server # Remote port forward
Subscribe to ONLY4YOU and get hands-on access to 40+ premium courses — Ethical Hacking, Kali Linux, Metasploit, Network Hacking, Bug Bounty & more!