How to use sudo and check your user
Overview
whoami prints the effective user. id shows user and group IDs. sudo runs an authorized command with elevated privileges, commonly as root.
Examples
whoami
id
groups
sudo apt update
sudo -k
How sudo behaves
- Enter your own account password when prompted; typed characters are not displayed
sudo -vrefreshes cached credentialssudo -kinvalidates cached credentials- Not every account is allowed to use sudo
- Prefer
sudo commandover opening a persistent root shell
Safety
Administrator commands can alter or erase the entire system. Understand the command, arguments, and paths before approving it.
Never paste an unknown command into sudo. Routine work in your home directory should normally not require elevated access.