Exam LFCS All QuestionsBrowse all questions from this exam
Question 41

What command will generate a list of user names from /etc/passwd along with their login shell?

    Correct Answer: D

    The correct command to generate a list of user names from /etc/passwd along with their login shell is 'cut -d: -f1,7 /etc/passwd'. The 'cut' command is used to extract specific fields or columns from a file. The '-d' option specifies the delimiter, which is ':' in the case of /etc/passwd, and the '-f' option specifies the fields to extract. In the /etc/passwd file, fields are separated by colons, with the first field being the user name and the seventh field being the login shell. Therefore, this command will correctly output the desired information.

Discussion
BuruguduystunstugudunstuyOption: D

The command that will generate a list of user names from '/etc/passwd' along with their login shell is 'cut -d: -f1,7 /etc/passwd'. Option D is the correct answer. The 'cut' command is used to extract specific fields or columns from a file. The '-d' option specifies the delimiter, and the '-f' option specifies the fields to extract. In this case, the command will extract the first ('1') and seventh ('7') fields from '/etc/passwd', using a colon (':') as the delimiter. The '/etc/passwd' file contains a list of user accounts on the system, with each line representing a single user. The fields are separated by colons, the first field is the user name and the seventh field is the login shell. Therefore, the command will generate a list of user names from '/etc/passwd' along with their login shell.

Buruguduystunstugudunstuy

The other options do not accurately describe the behavior of the 'cut' command: Option A: The 'column' command is used to format the output of a command into columns, but it does not have the capability to extract specific fields or columns from a file. Option B: The 'chop' command is not a standard Linux command. Option C: The 'colrm' command is used to remove specific columns from a file, but it does not have the capability to extract specific fields or columns from a file.