Determine Your Most Frequently Used Linux/Unix Commands

Written by Michael on September 24th, 2006

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.

Spruce up your comments with
<a href="" title=""><abbr title=""><acronym title=""><b><blockquote cite=""><cite><code><del datetime=""><em><i><q cite=""><strike><strong>
New comments are moderated before being shown * = required field

Leave a Comment





  • Blogroll
  • Cycling Links
  • Pages
  • Tags
  • Spam Blocked