Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file?
Which of the following commands prints a list of usernames (first column) and their primary group (fourth column) from the /etc/passwd file?
The correct command for printing specific columns from the /etc/passwd file is 'cut'. By specifying '-d :' we set the delimiter to a colon, which is the field separator in the /etc/passwd file. Using '-f 1,4' selects the first and fourth fields, which are the username and primary group ID respectively. Therefore, the command 'cut -d : -f 1,4 /etc/passwd' correctly extracts the required information.
The correct answer is C. cut -d : -f 1,4 /etc/passwd Explanation: cut is designed for extracting specific fields (columns) from delimited text files. -d : specifies the colon ":" as the delimiter. -f 1,4 selects the first (username) and fourth (primary group ID) fields. Here's why the other options are incorrect: fmt: Primarily used for formatting text and doesn't have options for field extraction. split: Divides files into smaller pieces based on size or number of lines, not fields. paste: Used to merge lines of files, not extract specific columns.