0
0
Linux CLIscripting~10 mins

whoami and id commands in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - whoami and id commands
Start
Run 'whoami'
Display current username
Run 'id'
Display user and group info
End
The flow shows running 'whoami' to get the username, then 'id' to get detailed user and group info.
Execution Sample
Linux CLI
whoami
id
This runs 'whoami' to show the current username, then 'id' to show user and group IDs.
Execution Table
StepCommandActionOutput
1whoamiGet current usernamealice
2idGet user and group IDsuid=1001(alice) gid=1001(alice) groups=1001(alice),27(sudo)
💡 Commands finish after displaying user info.
Variable Tracker
VariableStartAfter whoamiAfter idFinal
usernameundefinedalicealicealice
uidundefinedundefined10011001
gidundefinedundefined10011001
groupsundefinedundefined1001(alice),27(sudo)1001(alice),27(sudo)
Key Moments - 2 Insights
Why does 'whoami' only show the username but 'id' shows more details?
'whoami' simply prints the current username (see execution_table step 1), while 'id' shows user ID, group ID, and group memberships (see step 2).
Can 'id' show groups other than the main group?
Yes, 'id' lists all groups the user belongs to, not just the main group, as shown in the groups output in execution_table step 2.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the output of the 'whoami' command?
Aalice
Buid=1001(alice)
C1001
Dsudo
💡 Hint
Check the output column in execution_table row 1 for 'whoami' command.
At which step does the command show the user's group memberships?
AStep 1
BStep 2
CBoth steps
DNeither step
💡 Hint
Look at the 'Action' and 'Output' columns in execution_table for group info.
If the username was 'bob' instead of 'alice', how would the 'whoami' output change?
AIt would still show 'alice'
BIt would show the user ID number
CIt would show 'bob'
DIt would show group names
💡 Hint
Refer to variable_tracker for username changes after 'whoami'.
Concept Snapshot
whoami: shows current username
id: shows user ID, group ID, and groups
Use whoami for simple username
Use id for detailed user info
Both help identify current user context
Full Transcript
This visual execution shows how the 'whoami' command outputs the current username, and the 'id' command outputs detailed user and group information. First, 'whoami' runs and prints 'alice'. Then, 'id' runs and prints user ID, group ID, and group memberships. Variables like username, uid, gid, and groups update accordingly. Beginners often wonder why 'whoami' shows less info than 'id'—it's because 'whoami' only prints the username, while 'id' shows more details. Also, 'id' lists all groups the user belongs to, not just the main group. The quiz checks understanding of outputs and variable changes.