Bird
0
0

Which command correctly extracts the username and UID from /etc/passwd?

easy📝 Syntax Q3 of 15
Linux CLI - Users and Groups
Which command correctly extracts the username and UID from /etc/passwd?
Acut -d':' -f1,3 /etc/passwd
Bgrep -d':' -f1,3 /etc/passwd
Cawk -F',' '{print $1,$3}' /etc/passwd
Dsed -n '1,3p' /etc/passwd
Step-by-Step Solution
Solution:
  1. Step 1: Understand the /etc/passwd delimiter

    The fields in /etc/passwd are separated by colons (:), so the delimiter for cut must be ':'
  2. Step 2: Extract username and UID fields

    The username is field 1 and UID is field 3, so cut -d':' -f1,3 extracts these correctly.
  3. Final Answer:

    cut -d':' -f1,3 /etc/passwd -> Option A
  4. Quick Check:

    Correct delimiter and fields = cut -d':' -f1,3 /etc/passwd [OK]
Quick Trick: Use colon as delimiter with cut for /etc/passwd fields [OK]
Common Mistakes:
  • Using wrong delimiter in cut
  • Confusing grep with field extraction
  • Using wrong field separator in awk

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes