Linux Foundation Certified System Administrator (LFCS) — Question 122

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

Correct answer: C

Explanation

The correct answer is C, as the 'cut' command is specifically designed to extract sections from each line of a file based on specified delimiters, which in this case is ':' for the /etc/passwd file. Options A, B, and D do not perform the necessary function to extract the desired columns; 'fmt' and 'paste' are used for formatting and merging lines, while 'split' is used for dividing files into smaller pieces.