nerdexam
Linux_Foundation

LFCS · Question #829

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

The correct answer is D. cut -d: -f1,7 /etc/passwd. The cut command can extract specific fields from a delimited file like /etc/passwd, where fields are separated by a colon, to list usernames and their login shells.

Submitted by daniela_cl· Apr 18, 2026User and Group Management

Question

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

Options

  • Acolumn -s : 1,7 /etc/passwd
  • Bchop -c 1,7 /etc/passwd
  • Ccolrm 1,7 /etc/passwd
  • Dcut -d: -f1,7 /etc/passwd

How the community answered

(47 responses)
  • A
    4% (2)
  • B
    6% (3)
  • C
    2% (1)
  • D
    87% (41)

Why each option

The `cut` command can extract specific fields from a delimited file like `/etc/passwd`, where fields are separated by a colon, to list usernames and their login shells.

Acolumn -s : 1,7 /etc/passwd

`column` is used to format data into columns and does not have `-s` or direct field selection options like `1,7` for extraction in this manner.

Bchop -c 1,7 /etc/passwd

`chop` is not a standard Linux command for text processing like this; similar functionality might be found in `cut` or `awk`.

Ccolrm 1,7 /etc/passwd

`colrm` is used to remove columns from a file based on character positions, not delimited fields, and its syntax `1,7` would mean removing characters from position 1 to 7.

Dcut -d: -f1,7 /etc/passwdCorrect

The `cut` command with the `-d:` option specifies a colon as the delimiter, and `-f1,7` selects the first field (username) and the seventh field (login shell) from each line of `/etc/passwd`. This effectively extracts the desired information.

Concept tested: Extracting fields from delimited files

Source: https://man7.org/linux/man-pages/man1/cut.1.html

Topics

#cut command#/etc/passwd#User information#Text processing

Community Discussion

No community discussion yet for this question.

Full LFCS Practice