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
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
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.
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.