Skip to content
Advertisement

In Linux Shell, how to find out which commands I use most often and how often?

I want to find out which are the top 5 commands that I ran in the shell. I want to see which commands I use most often. It would be great if I can also see how often I ran these top commands.

Is there an easy way to find it without installing any plugins?

Advertisement

Answer

You can do it using history command and combine it with head -n to get the top n commands.

To get the top 5 commands:

history | awk '{print $2'} | sort | uniq -c | sort -rn | head -5

Result:

68 cd
66 ls
41 vi
40 git
24 rm

This means I have used cd most often, and I have used it 68 times.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement