Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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
  1

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

 
discard

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.