Home » Linux Administration

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

29 May 2008 No Comment


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: , , , , ,

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.