Bash command to determine multiple logins sorted by user with the most logins


Here ’tis

w | awk ‘{a[$1]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head

stumbled on this issue with a HP-UX server we run where the maxusers kernel paramater is set to 600 (512 by default). To change this setting, requires a reboot of the server (something not easily achievable at midday with 600 users logged in). You can change kernel parameters via SAM in HP-UX

This is a slight modification of the 1 liner that sorts your bash history by commands used:

history | awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head

Here’s some examples of my own from 2 machines:

235 ll
163 cd
149 grep
37 vi
32 for
31 du
26 rm
23 tail
21 htop
20 /etc/init.d/httpd

Here’s my home machine (I use pkill when I login to the same user desktop remotely via NX to kill evolution in the console session) :

109 ll
42 sudo
35 locate
35 cd
24 pkill
17 more
15 vi
15 unison
15 ssh
14 echo

Technorati Tags: , , , , ,

Published by salubrium

I am a Systems Administrator based in Sydney, Australia with some hugely varied interests: Topics covered are Virtualization, Web Hosting, Remote Desktop, Security and Backups, PHP, Python, MVC Frameworks, SEO

Leave a comment

Your email address will not be published.