Linux Local User and Group Enumeration
After landing a shell, mapping out users and groups tells you what accounts exist, which ones have elevated access, and what attack surface is available for privilege escalation or lateral movement. This is read-only enumeration — no modification, no exploitation.
Current User Context
Start by confirming who you are and what groups you belong to.
uid=1001(www-data) gid=1001(www-data) groups=1001(www-data),4(adm),27(sudo)
Group membership is as important as the UID. Membership in sudo, docker, disk, adm, lxd, or shadow all represent direct privilege escalation paths. See Group-Based Privilege Escalation on Linux.
All Local Users
Each line is username:x:UID:GID:comment:home:shell. Focus on:
UID 0 accounts other than root — any second UID-0 account is a backdoor
Accounts with a valid login shell (
/bin/bash,/bin/sh,/bin/zsh) — these can receive a shellService accounts with shells — misconfigured service accounts are common targets
Home directories — non-standard home paths sometimes contain credentials or keys
Filter to only accounts with login shells:
Filter to UID 0 accounts:
All Local Groups
Look for non-standard groups and check which users are members. Pay attention to groups that grant filesystem access, service control, or privilege paths:
Group | Risk |
|---|---|
sudo / wheel | Direct sudo access |
docker | Container escape to root |
lxd / lxc | Container escape to root |
disk | Raw disk read — access to shadow, keys |
adm | Read system logs — may contain credentials |
shadow | Read /etc/shadow directly |
staff | May write to system directories |
Sudo Group Members
These users can run sudo commands. Whether they need a password depends on sudoers configuration — check that separately during vulnerability discovery.
Currently Logged-In Users
w shows active sessions with TTY, source IP, and what command they are running. last shows recent login history. Both help identify active users whose sessions may be hijackable, or service accounts that log in from specific hosts.
User Home Directories
Readable home directories may contain .ssh/, shell history, application configs, and stored credentials. Note which home directories you can enter — that determines what post-exploitation is possible without escalating first.
If /root/ is readable, the box is already misconfigured badly — check for keys and flag files.
Password and Shadow Files
This is permission checking, not reading. If /etc/shadow is world-readable or /etc/passwd is world-writable, those are exploitable misconfigurations covered in /etc/passwd and /etc/shadow Privilege Escalation.
Service Accounts
Service accounts running daemons are worth mapping. If you can execute commands as a service account, you inherit its file access and group memberships.
Cross-reference the users running processes against /etc/passwd to see what shell and home they have.
Recent and Scheduled User Activity
Shows the last login for every account that has ever logged in. Stale accounts that have not been used in months are candidates for password spraying or direct abuse if credentials surface elsewhere.
Was this helpful?
Your feedback helps improve this page.