CompTIA Linux+ Powered by LPI (LX0-103) — Question 15
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. split -c 1,4 /etc/passwd
- C. cut -d : -f 1,4 /etc/passwd
- D. paste -f 1,4 /etc/passwd
Correct answer: C
Explanation
The correct command is 'cut -d : -f 1,4 /etc/passwd', which uses the colon as a delimiter to extract the first and fourth fields from the /etc/passwd file. The other options either use incorrect commands or incorrect syntax for extracting the desired fields, thus they will not yield the intended output.