0
0
Linux CLIscripting~10 mins

whoami and id commands in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to display the current logged-in username.

Linux CLI
[1]
Drag options to blanks, or click blank then click option'
Awhoami
Bid
Cpwd
Dls
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'whoami' to get only the username.
Using 'pwd' which shows current directory, not username.
2fill in blank
medium

Complete the code to display the user ID and group ID of the current user.

Linux CLI
[1]
Drag options to blanks, or click blank then click option'
Agroups
Bwhoami
Cid
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'whoami' which only shows username, not IDs.
Using 'groups' which shows only group names.
3fill in blank
hard

Fix the error in the command to show only the user ID number.

Linux CLI
id [1]
Drag options to blanks, or click blank then click option'
A-n
B-G
C-g
D-u
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-g' which shows group ID instead of user ID.
Using '-n' which is for name, not numeric ID.
4fill in blank
hard

Fill both blanks to display the primary group name of the current user.

Linux CLI
id [1] [2]
Drag options to blanks, or click blank then click option'
A-n
B-g
C-G
D-u
Attempts:
3 left
💡 Hint
Common Mistakes
Using -G which shows all group IDs, not primary group.
Mixing up user ID options with group options.
5fill in blank
hard

Fill all three blanks to create a dictionary in Python showing username and user ID using shell commands.

Linux CLI
user_info = { [1]: "$(whoami)", [2]: "$(id [3])" }
Drag options to blanks, or click blank then click option'
A"username"
B"uid"
C-u
D"gid"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "gid" instead of "uid" for user ID.
Forgetting quotes around dictionary keys.