System Management

An administrator needs the five usernames with the most login records in the output of last, where the username is the first field of each line. Which pipeline produces this list, highest count first?

Show the answer

Correct answerA. last | awk '{print $1}' | sort | uniq -c | sort -rn | head -5

Extracting the first field, sorting so identical names are adjacent, counting with uniq -c, then sorting numerically in reverse and taking the top five gives the result. Skipping the first sort is tempting, but uniq only collapses adjacent duplicates, so counts would be wrong.