Most used shell commands

I remember reading that “ls” was the most commonly used shell command. Not sure why I thought about it today but, it dawned on me that I could easily calculate it directly from my shell command history.

Years ago I went about configuring my shell command history options to my liking. Among several others are a) all my shells on my laptop (osx) share the same history file and b) the limit is set (arbitrarily) large at 99,999 (so I’m not sure why there’s only ~35k there, I’ll have to check that out, later).

So after a handful of piped shell commands here we go. It looks like “ls” has taken a back seat to “git” in my world. Also note that “vi” appears at #4 but I primarily use emacs for coding. That’s because I don’t run emacs from the shell and it stays up anyway. And yes my “vi” is aliased to “vim”, but I learned to type just “vi” long before “vim” was around. Looking at the oldest part of the history file I can tell that the oldest commands were typed sometime between 6 months ago and over a year ago. So I’ve typed ~35k commands in 6-12 months time, on my laptop. And my laptop is my primary work device.

count command
6072 git
5741 ls
1346 cd
3299 vi
1247 mysql
1181 more
1126 npm
1095 grep
954 ssh
727 node
541 cat
521 rm
419 curl
401 find
372 mv
323 sudo
298 cp
271 bash
205 ps
188 grunt
183 h
138 pbcopy
129 scp
127 which
114 pbpaste
114 man
110 mongo
109 find|grep
108 mutt
95 du
91 rsync
90 mkdir
86 test.js
85 brew
84 s3cmd
82 tail
77 emacsDebug.sh
74 echo
73 diff
72 wc
58 head
52 bc
51 df

That’s everything that occurs more than 50 times. If you are someone who’s wanting and/or needing to learn more shell commands (and who in their right mind would not!) this list is probably a good place to start.

TL;DR


48 heroku
46 crontab
44 global
42 parseEmails.js
41 ping
38 top
38 gtags
36 egrep
35 kill
33 rmdir
33 nodemon
31 mocha
30 for
29 touch
29 history
27 whois
27 procmail
27 chmod
26 webpack
26 tar
24 mysqldump
24 gctags
23 telnet
23 counts.sh
23 bower
22 babel
19 type
18 od
18 nslookup
16 at
14 gpg
13 sortuniqfile.sh
13 sort
13 file
12 locate
12 gunzip
12 gitclone
12 convert
11 sed
10 unzip
10 set|grep
10 php
10 date
9 mcrypt
9 ls|grep
9 ifconfig
9 ftp
8 jsync.sh
8 jshint
8 fetchmail.sh
8 cal
8 awk
7 while
7 sshTunnel
7 json.tool
7 ctags
7 atq
6 test.el
6 sortfile
6 pdftk
6 mongod
6 figlet
6 dupalllines.pl
5 splitName.js
5 openssl
5 ln
5 fg
4 make
4 launchctl
4 jpull.sh
4 ionic
4 formail
4 ffmpeg
4 exit
4 eslint
4 defaults
4 LiveTunnel.sh
3 swap.sh
3 sshTunnelKill
3 removeDblLfs
3 port
3 it
3 ifconfig|grep
3 identify
3 export
3 bunyan
3 brewupdate.sh
3 atrm
2 zip
2 wget
2 webpack-dev-server
2 uptime
2 unix2dos
2 test.sh
2 test.php
2 sshlive
2 python
2 perl
2 p
2 netstat
2 nc
2 mr
2 md5sum
2 ls|egrep
2 killall
2 kibana
2 ipconfig
2 hexdump
2 gzip
2 gs
2 gi
2 emacs
2 dos2unix
2 dirs
2 curry.js
2 curl.sh
2 create-react-app
2 counts
2 cmp
2 clear
2 certbot
[1's snipped]

And here’s the string of piped commands to produce it;

$ history | awk '{print $2}' | sort | uniq -c | sort -nr

Then for the total, pipe on another awk to sum the col of numbers;

$ history | awk '{print $2}' | sort | uniq -c | sort -n | awk '{ sum += $1; } END { print sum; }' $1
36038

Looking over my history and doing some greping and sorting points out other things that might be of interest;

Q: Out of the ~36k command history how many are piped?
A:

$ history | grep '|' | wc
1824 11628 71428

That’s 1824 piped commands. And that leads me to call out a few interesting pipes, in another post, here:

Shell Commands Piped together

Also read about Mastering the shell