Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to get a list that shows how many times each user logged in to the system.

Something along the lines

user1 45
user2 134
user3 200
share|improve this question
up vote 5 down vote accepted
 last | cut -d' ' -f1 | sort | uniq -c | sort -rn

It'll output something like:

189 user1
 73 user2
  7 reboot
  1 wtmp

When the username column contain 'reboot' it means system reboot, not a login. When the username column contain wtmp or it's empty it's also not a login.

share|improve this answer
last | cut -d' ' -f1| awk '{ users[$0]++ } END { for(w in users) { print users[w],w }}' | sort -n

Similar to dvb's answer but with awk.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.