Skip to content

whoami

13 commands

Prints the effective user name — the first question after landing a shell.

  • users
  • privilege

Install whoami

sudo apt install coreutils

Identity6

whoami

Prints the effective user name.

id

User ID, primary group and every supplementary group. Groups like sudo, wheel, docker, lxd or disk often mean a path to root.

id <user>

Another user’s IDs and groups.

Link
groups

Just the group names.

logname

The user who originally logged in, even after su or sudo.

echo $USER $HOME $SHELL

Common identity environment variables.

Privileges3

sudo -l

Lists what you may run with sudo. Entries marked NOPASSWD and editable scripts are classic escalation paths.

sudo -n true && echo yes

Checks whether sudo works without a password.

getcap -r / 2>/dev/null

Binaries with Linux capabilities such as cap_setuid that can lead to root.

Who else is here4

who

Users logged in now, their terminals and where they came from.

Link
w

Logged-in users plus what each is running and how long they have been idle.

Link
last -n 20

Recent logins and reboots from /var/log/wtmp.

Link
lastlog

The last login of every account.

Link