Linux gets a list of the 10 most common terminal commands you use

  • 2020-12-07 04:38:53
  • OfStack

I think my most common command is:

Choices cd git ls ssh sudo

A few weeks ago I stumbled upon this Reddit thread a short snippet of Bash that tells me how to get a list of my most commonly used terminal commands.


history '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' column

The details are not very important, but basically, it takes the output of the historical command, summarizes it, and tells you what the top 10 commands were, and what percentage of the time each command was used. You can easily make a few changes to the code snippet to get a longer list, or change the format slightly. This is from my recently updated laptop.


  1 138 25.0909% sudo
  2 59 10.7273% ls
  3 47 8.54545% cd
  4 20 3.63636% git
  5 19 3.45455% grep
  6 13 2.36364% vi
  7 10 1.81818% lpstat
  8 9 1.63636% find
  9 8 1.45455% ps
 10 8 1.45455% htop

The only one that surprised me was lpstat(I've been struggling with printer configuration lately). These numbers are not very large, and some of the details are hidden behind sudo (most likely many of them are DNF updates). Curiously, I ran the same commands on my desktop and on several virtual machines, which were used for different purposes and got very different results.

I spend a fair amount of time using ssh on my desktop. In the virtual machine, both systemctl and docker have lists, and vi jumped to the top of my list when I spent a lot of time editing configuration files.

Your top 10 probably share 1 thing about you as well. Are you a developer? 1 power user? Do you often use remote systems? What's your favorite text editor?
Share your top 10, or best tools, if you'd like. Did your list surprise you? Is it the same as you think?

conclusion


Related articles: