List the commands that the current user is allowed or denied to run through sudo.
Do not execute an administrative command.
Which command is appropriate?
sudo -l lists Defaults and command permissions that apply to the current user on the current host.
Detailed explanation
sudo -vIncorrect. sudo -v validates or refreshes credentials.
Incorrect. sudo -v validates or refreshes credentials.
sudo -kIncorrect. sudo -k invalidates cached credentials.
Incorrect. sudo -k invalidates cached credentials.
sudo -u rootIncorrect. It lacks a command and does not request a policy listing.
Incorrect. It lacks a command and does not request a policy listing.
sudo -lCorrect. It lists the user's sudo privileges.
Correct. It lists the user's sudo privileges.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-l=list privileges' '-v=validate credentials' '-k=invalidate timestamp' '-u=target user'Expected result
-l=list privileges
-v=validate credentials
-k=invalidate timestamp
-u=target userKey points
- -l means list
- Inspect policy first
- Different privilege model from su
Notes
- Environment: sudo option対応表
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.