Bird
0
0

Given the following command:

medium📝 Command Output Q13 of 15
Linux CLI - Users and Groups
Given the following command:
grep '^root:' /etc/passwd | cut -d':' -f1,3,7

What will be the output format?
Aroot:/bin/bash
Broot:x:0:0:root:/root:/bin/bash
Croot:0:0
Droot:0:/bin/bash
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command parts

    grep '^root:' /etc/passwd finds the line starting with 'root:'. cut -d':' -f1,3,7 extracts fields 1 (username), 3 (UID), and 7 (shell) separated by colons.
  2. Step 2: Identify root line fields

    Typical root line: root:x:0:0:root:/root:/bin/bash. Fields: 1=root, 2=x, 3=0, 4=0, 5=root, 6=/root, 7=/bin/bash.
  3. Step 3: Extract fields 1,3,7

    Fields 1=root, 3=0, 7=/bin/bash. Joined by colons: root:0:/bin/bash.
  4. Final Answer:

    root:0:/bin/bash -> Option D
  5. Quick Check:

    Fields 1,3,7 from /etc/passwd line = root:0:/bin/bash [OK]
Quick Trick: Count fields carefully; cut -f1,3,7 picks username, UID, shell [OK]
Common Mistakes:
MISTAKES
  • Mixing up field numbers in cut command
  • Expecting full /etc/passwd line output
  • Confusing shadow file format with passwd

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes