Linux Commands Cheat Sheet
Essential Linux command-line reference — files, permissions, processes, networking, and search for everyday and pentest use.
Overview
The core Linux commands you reach for constantly: navigating the filesystem, managing permissions and processes, inspecting the network, and finding things. A solid base for sysadmin work and the foundation for post-exploitation enumeration on a foothold.
Authorized use only. Run commands only on systems you own or have permission to access.
Files & navigation
List all files with details and hidden ones
ls -laJump back to the previous directory
cd -Copy / move / remove
cp -r src dst / mv src dst / rm -rf dirFind files by name (suppress errors)
find / -name '*.conf' 2>/dev/nullCreate / extract a gzip tarball
tar czf out.tar.gz dir/ / tar xzf out.tar.gzCreate a symlink
ln -s /target linknameViewing & searching text
Print / page / first lines / follow a log
cat / less / head -n 20 / tail -f fileRecursive, case-insensitive search with line numbers
grep -rin 'pattern' /pathExtract only matching parts (IPs here)
grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' filePrint a field split on a delimiter
awk -F: '{print $1}' /etc/passwdCount and rank unique lines
sort file | uniq -c | sort -rnPermissions & ownership
Set numeric perms / make executable
chmod 755 file / chmod +x script.shChange owner and group
chown user:group fileList what you can run as root (key for privesc)
sudo -lFind SUID binaries
find / -perm -4000 -type f 2>/dev/nullShow the default permission mask
umaskProcesses & system
List and filter processes
ps aux | grep procLive process/resource monitor
top / htopForce-kill by PID / by name
kill -9 PID / pkill nameDisk free / per-item disk usage
df -h / du -sh *Service status / its logs
systemctl status sshd / journalctl -u sshdKernel / distro info
uname -a / cat /etc/os-releaseNetworking
Interfaces and addresses / routing table
ip a / ip routeListening TCP/UDP sockets with PIDs
ss -tulpnShow your public IP
curl -s ifconfig.meReachability / DNS lookup
ping -c 4 host / dig hostCopy a file over SSH
scp file user@host:/tmp/Handy one-liners
Re-run the last command with sudo
sudo !!Search your command history
history | grep sshMake all .sh files executable
find . -name '*.sh' -exec chmod +x {} +Watch a command refresh every 2s
watch -n2 'ss -tulpn'Show the 10 largest files under a path
du -ah /var | sort -rh | head -10Tips
- Append 2>/dev/null to find/grep to hide permission-denied noise.
- sudo -l is the first command to run on a new shell — it often reveals an instant privesc.
- Use 'man cmd' or 'cmd --help' when unsure; 'tldr cmd' gives quick examples if installed.
- ss has replaced netstat on modern systems — ss -tulpn is the go-to for listening ports.