The file /etc/passwd has colon-separated fields. Type the complete command that prints only the third field (the UID) of every line, using cut and passing the file as an argument.

LPIC-1 Exam 101-500, objective 103. GNU and Unix commands medium

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

Answer

Type the answer.

Accepted answers

Case sensitive — Linux is, and grading LS as ls would teach a falsehood.

Why

cut -d sets the field delimiter and -f selects the fields; -f3 is one field, -f1,3 a list, -f1-3 a range. Without -d, cut assumes TAB, which is why cutting fields out of a space-aligned listing usually fails. -c selects character positions instead of fields.

Where this comes from

Cited
LPI exam objective 103.2
What it says
Extract fields from a delimited text stream with cut.

Practise this

Reading one question is not practice. The trainer will draw a set from objective 103 and space the ones you get wrong.

Practise LPIC-1 Exam 101-500