Bird
0
0

You want to write a script that prints the username and primary group name separated by a colon, like alice:staff. Which command combination is correct?

hard📝 Application Q8 of 15
Linux CLI - Users and Groups
You want to write a script that prints the username and primary group name separated by a colon, like alice:staff. Which command combination is correct?
Aecho "$(whoami) $(id -g)"
Becho "$(id -u):$(id -g)"
Cecho "$(whoami):$(id -gn)"
Decho "$(id -un):$(id -g)"
Step-by-Step Solution
Solution:
  1. Step 1: Identify commands for username and group name

    whoami gives username, id -gn gives primary group name.
  2. Step 2: Check command formatting

    echo "$(whoami):$(id -gn)" correctly uses command substitution and colon separator.
  3. Final Answer:

    echo "$(whoami):$(id -gn)" -> Option C
  4. Quick Check:

    Use whoami and id -gn for username:group [OK]
Quick Trick: Use command substitution $(...) to combine outputs [OK]
Common Mistakes:
MISTAKES
  • Using numeric IDs instead of names
  • Missing colon separator
  • Mixing username with group ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes