0
0
Linux CLIscripting~20 mins

whoami and id commands in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
User Identity Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
Output of whoami command
What is the output of the whoami command when run by a logged-in user named alice?
Linux CLI
whoami
Aid
Balice
Cusers
Droot
Attempts:
2 left
💡 Hint
The whoami command shows the current user's login name.
💻 Command Output
intermediate
1:30remaining
Understanding id command output
What does the id command output show when run by user bob with UID 1001, GID 1001, and groups 1001 and 27?
Linux CLI
id
Auser=bob uid=1001 gid=1001 groups=1001,27
Bbob 1001 1001 27
Cuid=1001(bob) gid=1001(bob) groups=1001(bob),27(sudo)
Duid=bob gid=1001 groups=27
Attempts:
2 left
💡 Hint
The id command shows user ID, group ID, and group memberships with names.
🧠 Conceptual
advanced
1:30remaining
Difference between whoami and id commands
Which statement correctly describes the difference between whoami and id commands?
A<code>whoami</code> shows only the current username; <code>id</code> shows user and group IDs and group memberships.
B<code>whoami</code> shows user and group IDs; <code>id</code> shows only the username.
C<code>whoami</code> shows all logged-in users; <code>id</code> shows current user only.
D<code>whoami</code> shows group memberships; <code>id</code> shows the current username.
Attempts:
2 left
💡 Hint
Think about what each command prints about the user.
💻 Command Output
advanced
1:30remaining
Output of id command with multiple groups
What is the output of id for user carol with UID 2000, GID 3000, and groups 3000, 4, and 27, where group 4 is 'adm' and 27 is 'sudo'?
Linux CLI
id
Auid=carol gid=3000 groups=4,27
Buid=2000 gid=3000 groups=carol,adm,sudo
Ccarol 2000 3000 4 27
Duid=2000(carol) gid=3000(carol) groups=3000(carol),4(adm),27(sudo)
Attempts:
2 left
💡 Hint
The id command shows numeric IDs and group names.
💻 Command Output
expert
1:00remaining
Error when running id with invalid option
What error message appears when running id --unknown on a Linux system?
Linux CLI
id --unknown
A
id: unrecognized option '--unknown'
Try 'id --help' for more information.
Bid: invalid argument '--unknown'
Cbash: id: command not found
Did: option requires an argument -- 'unknown'
Attempts:
2 left
💡 Hint
Invalid options usually produce a message about unrecognized option.