LPIC-1 Exam 101 v5 (Linux Administrator) — Question 109
Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file?
Answer options
- A. fmt -f 1,4 /etc/passwd
- B. cut -d : -f 1,4 /etc/passwd
- C. sort -t : -k 1,4 /etc/passwd
- D. paste -f 1,4 /etc/passwd
- E. split -c 1,4 /etc/passwd
Correct answer: B
Explanation
The correct command is B, as 'cut' is specifically designed to extract sections from each line of a file based on a specified delimiter, in this case, ':' for the /etc/passwd file. The other commands do not serve this purpose: A uses 'fmt', which formats text, C sorts data rather than extracting it, D pastes lines together, and E splits files rather than extracting fields.