whoami
which user am Iwhoami prints one word: the account the shell is running as. It matters after su or sudo, when that may no longer be the account you logged in with — and before any command that would be dangerous as root.
One word, and worth checking: are you root right now, or yourself?
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
The name the shell is running under — the same one in the prompt.
The command ran as root, so that is what it reports. It is a quick way to confirm that sudo works for you.
sudo -u runs a command as a named account. Running whoami this way tests whether you are allowed to.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
idShows the user id, group id and every group you belong to.
whoLists everyone logged in to the machine.
echo $USERThe same name, from an environment variable.
lognameThe name you originally logged in as, even after su.
In cybersecurity
It is the first command run on any newly gained shell.
After exploiting a service, whoami shows which account was obtained. www-data means there is more work to do; root means there is not.
A root prompt usually ends in # rather than $. If in doubt, ask — before running rm or chown, not after.
A web application that reports root when it runs whoami is running with far more power than it needs.