DEV Community

Abhinav Kumar
Abhinav Kumar

Posted on • Edited on

What are the most used commands in your shell history?

Recently I came across a thread on reddit which asked users the most used command in their shell history.

My results:

     1  419  13.0489%    git
     2  265  8.25288%    cd
     3  239  7.44316%    sudo
     4  122  3.79944%    cat
     5  77   2.39801%    which
     6  76   2.36686%    dkr
     7  72   2.24229%    rm
     8  60   1.86858%    rg
     9  57   1.77515%    yarn
    10  57   1.77515%    nvim
Enter fullscreen mode Exit fullscreen mode

Obviously git is my most used command because I ran it on my work laptop. It should be a lot more but I have been using prezto's git aliases lately. Other common commands are dkr which is an alias for sudo docker and rg, the binary for ripgrep.

I wonder how is it for the dev.to community?

Use this command from linux.byexample.com to list your most used 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
Enter fullscreen mode Exit fullscreen mode

I use zsh and it was not working for me because zsh's history command just prints a few most recent commands only. I had to tweak it a bit:

history 1 | cat | 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
# or
fc -l 1 | 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
Enter fullscreen mode Exit fullscreen mode

Latest comments (31)

Collapse
 
leojpod profile image
leojpod
     1  536  20.727%     gcam
     2  312  12.065%     gco
     3  124  4.79505%    npm
     4  124  4.79505%    gc
     5  121  4.67904%    ga
     6  111  4.29234%    git
     7  105  4.06032%    elm
     8  97   3.75097%    rm
     9  75   2.90023%    docker-compose
    10  54   2.08817%    g

aka a bunch of git shortcuts, the infamouse npm for npm start on all my projects, yet more git stuff
number 11 is nvim with 51 :D

Collapse
 
nmcain profile image
Noah Cain

     1  43  17.0635%   cd
     2  37  14.6825%   flutter
     3  31  12.3016%   ls
     4  27  10.7143%   git
     5  22  8.73016%   webdev
     6  14  5.55556%   nano
     7  11  4.36508%   sudo
     8  10  3.96825%   adb
     9  8   3.1746%    pub
    10  7   2.77778%   rm

Flutter, am I right?

Collapse
 
eddinn profile image
Edvin Dunaway • Edited
 1  274  27.4%  ssh
 2  118  11.8%  ping
 3  56   5.6%   ls
 4  55   5.5%   vim
 5  52   5.2%   cd
 6  47   4.7%   cat
 7  46   4.6%   sudo
 8  38   3.8%   grep
 9  31   3.1%   find
10  24   2.4%   gf
11  21   2.1%   ll
12  21   2.1%   less
13  16   1.6%   gp
14  15   1.5%   rm
15  15   1.5%   la
16  15   1.5%   dnfd
17  11   1.1%   git
18  10   1%     cpp
19  9    0.9%   diff
20  8    0.8%   chmod

I mainly work via ssh, so my total commands differ there.

Collapse
 
nirebu profile image
Nicolò Rebughini

On my main VM lots of DNS queries, talking to other machines and inline loops; and oh, some heavy ansible testing made its way to the top 10

     1  192  19.2%  dig
     2  153  15.3%  ssh
     3  107  10.7%  cd
     4  104  10.4%  sudo
     5  52   5.2%   rm
     6  50   5%     for
     7  46   4.6%   split
     8  44   4.4%   scp
     9  39   3.9%   ansible-playbook
    10  20   2%     ll
Collapse
 
vlasales profile image
Vlastimil Pospichal
     1  117  12.4468%   ll
     2  113  12.0213%   xmllint
     3  92   9.78723%   vim
     4  45   4.78723%   php
     5  39   4.14894%   cd
     6  36   3.82979%   mv
     7  34   3.61702%   git
     8  28   2.97872%   cat
     9  27   2.87234%   docker
    10  24   2.55319%   mongo
Collapse
 
tsia profile image
tsia
     1  1073  10.73%  sudo
     2  852   8.52%   cd
     3  795   7.95%   ssh
     4  522   5.22%   dig
     5  455   4.55%   curl
     6  412   4.12%   vi
     7  368   3.68%   git
     8  304   3.04%   rm
     9  283   2.83%   ls
    10  249   2.49%   cat

I'm more of a sysadmin guy as you might have guessed by git being only on 7 :D

Collapse
 
igormp profile image
Igor Moura
     1  997  12.7023%    exit
     2  992  12.6386%    git
     3  916  11.6703%    sudo
     4  295  3.75844%    ping
     5  266  3.38897%    cd
     6  261  3.32526%    yaourt
     7  212  2.70098%    ls
     8  138  1.75819%    startx
     9  126  1.6053%     cat
    10  110  1.40145%    qemu-system-x86_64

I honestly didn't expect qemu to be there lol

Collapse
 
mjb2kmn profile image
MN Mark
 1  169  33.8%  ssh
 2  58   11.6%  git
 3  45   9%     cd
 4  44   8.8%   ll
 5  26   5.2%   vim
 6  23   4.6%   dig
 7  22   4.4%   exit
 8  17   3.4%   vi
 9  15   3%     clear
10  8    1.6%   ping

I might be a software engineer by title, but really a sysadmin by necessity.
I didn't expect to see exit and clear so much but I suppose it makes sense with all the tmux panes being created and destroyed and my habit of clearing the screen when switching between tasks.

Collapse
 
abhinav profile image
Abhinav Kumar

Ctrl+D and Ctrl+L?

Collapse
 
c0il profile image
Vernet Loïc

Git also wins for me. :) php would be second when combining php and sf.

 1  393  23.632%     git
 2  128  7.69693%    cd
 3  120  7.21587%    sf
 4  75   4.50992%    php
 5  54   3.24714%    rm
 6  54   3.24714%    kf.preprod3
 7  52   3.12688%    grep
 8  49   2.94648%    redis-cli
 9  46   2.76609%    composer
10  42   2.52556%    ping
  • sf is an alias for php app/console
  • kf.preprod3 is a ssh alias
Collapse
 
simov profile image
simo
     1  301  30.1%  g
     2  162  16.2%  cd
     3  105  10.5%  ll
     4  87   8.7%   npm
     5  43   4.3%   s
     6  32   3.2%   sudo
     7  30   3%     rm
     8  20   2%     node
     9  19   1.9%   mocha
    10  17   1.7%   nvm

g - git, s - sublime

Collapse
 
abhinav profile image
Abhinav Kumar

Are you using self-defined aliases for git or the ones defined by a bash/zsh framework?

Collapse
 
simov profile image
simo

I've manually added the following lines in my .bashrc file:

# git alias and autocomplete
alias g='git'
source /usr/share/bash-completion/completions/git
complete -o default -o nospace -F _git g