ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 163 - XK0-005 discussion

Report
Export

A systems administrator wants to list all local accounts in which the UID is greater than 500. Which of the following commands will give the correct output?

A.
find /etc/passwd -size +500
Answers
A.
find /etc/passwd -size +500
B.
cut -d: fl / etc/ passwd > 500
Answers
B.
cut -d: fl / etc/ passwd > 500
C.
awk -F: ‘$3 > 500 {print $1}' /etc/passwd
Answers
C.
awk -F: ‘$3 > 500 {print $1}' /etc/passwd
D.
sed '/UID/' /etc/passwd < 500
Answers
D.
sed '/UID/' /etc/passwd < 500
Suggested answer: C

Explanation:

The correct command to list all local accounts in which the UID is greater than 500 is:

awk -F: '$3 > 500 {print $1}' /etc/passwd

This command uses awk to process the /etc/passwd file, which contains information about the local users on the system. The -F: option specifies that the fields are separated by colons. The $3 refers to the third field, which is the UID. The condition $3 > 500 filters out the users whose UID is greater than 500. The action {print $1} prints the first field, which is the username.

The other commands are incorrect because:

find /etc/passwd -size +500 will search for files that are larger than 500 blocks in size, not users with UID greater than 500.

cut -d: fl / etc/ passwd > 500 will cut the first field of the /etc/passwd file using colon as the delimiter, but it will not filter by UID or print only the usernames. The > 500 part will redirect the output to a file named 500, not compare with the UID.

sed '/UID/' /etc/passwd < 500 will use sed to edit the /etc/passwd file and replace any line that contains UID with 500, not list the users with UID greater than 500. The < 500 part will redirect the input from a file named 500, not compare with the UID.

Reference:

Linux List All Users In The System Command - nixCraft, section "List all users in Linux using /etc/passwd file".

Unix script getting users with UID bigger than 500 - Stack Overflow, section "Using awk".

asked 02/10/2024
Mathias Bergman
25 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first