Security work lives in a terminal. Before Burp, before Metasploit, you need to be at home in a Linux shell. These 30 commands are the ones I use daily, grouped by task. Practice them until they're boring โ then they're ready.
1. Getting Around
pwd
ls -la
cd /var/log
tree -L 2
man grep
ls -la output deserves attention โ the leading characters are permissions:
-rwxr-xr-x 1 root root ... /usr/bin/nmap
^ ^^^^^^^^ ^^ ^^^^
| owner perms | owner group
| read/write/execute for each
Read permission bits as a security professional. rwxr-xr-x means "anyone can execute, only owner can modify" โ that's normal. rwsr-xr-x is a SUID bit and immediately interesting for privilege escalation.
2. Finding Things
find / -name "*.conf" 2>/dev/null
find / -perm -4000 2>/dev/null
find / -type f -mtime -7 2>/dev/null
grep -ri "password" /etc/ 2>/dev/null
3. Reading and Processing
cat /etc/passwd
head -20 file
tail -f /var/log/auth.log
less file
awk '{print $3}' /etc/passwd
cut -d: -f1 /etc/passwd
[!TIP]
less beats cat for anything over a screen. / searches inside, G jumps to the end.
4. Users, Groups, Processes
whoami
id
groups
ps aux
ps aux | grep -i nginx
top / htop
/etc/passwd columns you'll cite in writeups:
username:x:1001:1001:User:/home/user:/bin/bash
^^^^ ^^^^ ^^^^^^^^
uid | | home shell
gid | |
| group
5. Networking (You Will Use These Daily)
ip a
ip r
ss -tulpn
ping -c 4 10.10.10.5
curl -I http://target
nc -lvnp 4444
tcpdump -i eth0 port 80
ss -tulpn is the single most useful command for "what is running on this box":
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=812,fd=3))
LISTEN 0 128 127.0.0.1:5432 0.0.0.0:* users:(("postgres",pid=900,fd=7))
Notice 127.0.0.1:5432 โ a database bound to loopback only. That detail is a whole finding by itself.
6. Permissions and Ownership
chmod 600 secret.txt
chmod 755 script.sh
chown user:group file
sudo su -
sudo -l
7. Services and Packages
systemctl status nginx
systemctl list-units --type=service --state=running
apt list --upgradable
dpkg -l | grep -i openjdk
Cron is where surprise automation hides:
crontab -l
ls -la /etc/cron.* /var/spool/cron/
[!WARNING]
- On a compromised or pentested box, always check cron and systemd timers before trusting any process. Scheduled jobs are the classic persistence mechanism โ and a classic privilege escalation vector when they run as root.
8. Files and Archives
tar -xzf backup.tar.gz
unzip archive.zip
gzip -d file.gz
md5sum file
file unknown
9. History and Logs
history | tail -30
cat /var/log/auth.log | grep -i fail
last -20
journalctl -u ssh -n 50
10. Text Power Moves
sort file | uniq -c | sort -rn
wc -l file
sed 's/foo/bar/g' file
echo "hello" | xargs -I{} echo "got: {}"
The Daily Loop
When I get a new box, the first five minutes are always:
whoami && id
uname -a && cat /etc/os-release
ip a
ss -tulpn
sudo -l
crontab -l
Twelve seconds of typing, and you know who you are, what the box is, what's listening, and what you can escalate to. Everything else builds on that.
Discussion (0)
Sign in or create an account to join the discussion.
No comments yet. Start the discussion.