List your sudo privileges with `sudo -l`
Before pasting a sudo command from a tutorial, or when writing automation, `sudo -l` shows precisely what your account is allowed to run — and what will be rejected.
01Command
$ sudo -l02What it does
The output first shows sudoers entries that apply to your account, then 'User X may run the following commands'. An entry like `(ALL : ALL) ALL` means unrestricted access, while `(ALL) NOPASSWD: /usr/bin/systemctl restart nginx` allows only that exact command without a password. To audit another user instead, `sudo -l -U username` lists their privileges without switching accounts. Combined with `sudo -k` (clear the cached credential timestamp) it is also how you re-test a policy change immediately.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- sudo(8) — execute a command as another userEvidence: Documents -l (list command(s) the invoking user may run) and -U for listing another user's privileges
Last verified: 2026-09-17 · Category: Security & Privacy