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: bash, hp-ux, linux, one-liner, awk, maxusers
About this entry
You’re currently reading “Bash command to determine multiple logins sorted by user with the most logins,” an entry on opensourcetutor.com
- Published:
- 29.05.08 / 12pm
- Category:
- Linux Administration
- Tags:
- No Tags
- Related Posts:
- No Related Posts
No comments
Jump to comment form | comments rss [?] | trackback uri [?]