Rain City Story

24Sep/060

Determine Your Most Frequently Used Linux/Unix Commands

If you're using the Bourne Again Shell (bash), type:

history|awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}'|sort|uniq -c|sort -r -n

This will print them commands you used most often to your terminal. Why is this handy? Well if you see a command that you use often and it's fairly long, it might be time to make an alias or perhaps you see a group of commands that you can concatenate the output using pipes and a single alias. You don't need to be root to do this obviously but I happened to have a root terminal open on one of my webhosting machines to make this example.

bash_history1.png

In my example, you can see that I hit vnstat (a simple yet incredibly accurate bandwith monitor) a lot in addition to a custom perl script I wrote to graph it's output using rrdtool. I had some serious bandwidth concerns a few months ago due to a few of my customers' sites that had become incredibly popular in a very short period of time.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.