Which Linux terminal command do you use the most?

The commands you use can tell us something about where your work, or perhaps you passion, drives you at the terminal.
228 readers like this.
3 warning flags of DevOps metrics

Opensource.com

A few weeks back I stumbled across this Reddit thread with a short Bash snippet telling me how to get a list of my most-used terminal commands.

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

The details aren't terribly important, but basically, it takes the output of the history command, totals it up, and tells you what your top ten commands have been and what percentage of the time each had been used. You could pretty easily make some modifications to the snippet to get a longer list, or change the formatting a bit. Here's mine from my fairly-recently-refreshed 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 item in there that surprised me was lpstat (I had been fighting with a printer configuration recently). These numbers weren't terribly big, and some of the details were hidden behind sudo (likely a lot of those were dnf updates). So curious, I ran the same command on my desktop and on a couple of virtual machines I'd used for different purposes and got very different results.

On my desktop, I spend a considerable amount more time using ssh. And in the virtual machines, systemctl and docker both make the list, and vi climbs to the top as I spend a lot of time editing configuration files.

Your top ten probably shares something about you, too. Are you a developer? A power user? Do you work a lot with remote systems? What's your favorite text editor? If you're willing, share your top ten list in the comments below, or perhaps just the top tool. Did your list surprise you? Why or why not?

User profile image.
Jason was an Opensource.com staff member and Red Hatter from 2013 to 2022. This profile contains his work-related articles from that time. Other contributions can be found on his personal account.

18 Comments

What about 'man" to look up man pages. So many options to look up!

I think, most popular command is ''df-mh'' )

Mine was python, then ls

Here are my top ten:

1 105 21% git
2 61 12.2% cd
3 56 11.2% ls
4 41 8.2% docker
5 37 7.4% ssh
6 27 5.4% docker-compose
7 21 4.2% dig
8 21 4.2% curl
9 15 3% rm
10 12 2.4% less

This is pretty cool. If you want to see what's behind the sudo commands you can add a sed command right after history like so

$ history | sed 's/sudo // -g' | awk

On servers I log into only for a command or two at a time, the winner, by a large margin, is "exit."

My top-10:
1 730 23.4425 % git
2 497 15.9602 % ll
3 219 7.03276 % brew
4 169 5.4271 % ssh
5 147 4.72062 % unison
6 138 4.4316 % wc
7 129 4.14258 % cat
8 117 3.75723 % cd
9 107 3.4361 % cargo
10 91 2.92229 % sem

as user, pass
as root, apt
ls is second in both cases.

This is what I got on my laptop I use for work, would be interesting to compare it with my desktop I use for personal use.

1 220 22% sudo
2 212 21.2% ssh
3 70 7% ping
4 62 6.2% ls
5 42 4.2% cd
6 28 2.8% vim.tiny
7 24 2.4% scp
8 24 2.4% python3
9 22 2.2% ps
10 20 2% man

Here's mine:
1 265 26.5% cls (an alias of clear)
2 162 16.2% ssh
3 153 15.3% dig
4 41 4.1% whois
5 27 2.7% cd
6 18 1.8% vim
7 18 1.8% ll
8 15 1.5% sudo
9 14 1.4% VPS (an alias to connect to my server)
10 8 0.8% rpm

I use a Mac, and i tried this
1 71 14.257% echo
2 29 5.82329% awk
3 14 2.81124% expr
4 14 2.81124% ((
5 12 2.40964% time
6 12 2.40964% sed
7 11 2.20884% grep
8 11 2.20884% clear
9 11 2.20884% cd
10 10 2.00803% curl

What i usually make is scripts for scraping web-pages, locating stuff in files and doing stuff automaticcaly for u

Here are my results. I use SSH a lot to access other hosts on my internal network.

1 198 19.8% ssh
2 97 9.7% ls
3 84 8.4% dnf
4 76 7.6% cd
5 34 3.4% exit
6 33 3.3% mc
7 26 2.6% screen
8 26 2.6% mount
9 25 2.5% ping
10 19 1.9% cat

Also, the histories of different terminal emulators and terminals inside screen will have differing and divergent numbers the longer they are open and in use. This is because all terminal sessions start their history with whatever is in the history file when they are launched. As you work in the different terminal sessions their more recent histories are not shared with other sessions so they will tend to diverge at least a little.

I also find the different between root and non-root usage very enlightening. The sample above was from a root session and the one below is from my own user ID.
1 466 46.6% task
2 82 8.2% ll
3 58 5.8% mv
4 46 4.6% cd
5 46 4.6% cat
6 44 4.4% ls
7 26 2.6% su
8 25 2.5% exit
9 22 2.2% tar
10 17 1.7% mc

Note that the task command is the most frequent by far. It is a command line task manager that I started using last year and I obviously use it a lot.

Wow! What fun and I learned something new. Neat awk program, Jason.

I thought "ls" would have been the most used for me, but it's "sudo" followed by "ssh". I remote too much, apparently. :-)

1 224 22.4224% sudo
2 103 10.3103% ssh
3 80 8.00801% ls
4 66 6.60661% cd
5 37 3.7037% exit
6 32 3.2032% dmesg
7 28 2.8028% youtube-dl
8 22 2.2022% bc
9 19 1.9019% while
10 19 1.9019% screenfetch

pacman -Syu
pacman -Sc
pacman -Qqdt

"cd" the most, but "history" a lot.

"ls" is the most used, but "vi" and "ansible-playbook" came right after it. I was surprised with the results !

You can use this to skip the sudo command and save the user called as super user, example "sudo yum update -y" will save the yum command instead of sudo

history | awk '{total+=1;if($2=="sudo"){commands[$3]+=1}else{commands[$2]+=1}} END{for(command in commands){print command " " commands[command] " " commands[command]/total*100}}' | column -t -s " " | sort -k3 -r -n | nl | head -10

1 62 6.2% rsync
2 53 5.3% ds
3 50 5% cd
4 45 4.5% sshl
5 35 3.5% man
6 33 3.3% f
7 32 3.2% zenity
8 29 2.9% vi
9 29 2.9% testati.pl
10 27 2.7% convert

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.