What are your five most used terminal commands?

riscie on May 15, 2019

I start: 1 1874 18.3942% git 2 709 6.95917% sudo 3 622 6.10522% cd 4 565 5.54574% kubectl 5 ... [Read Full]
markdown guide
 

This version works for zsh (OSX/oh-my-zsh here):

history | \
awk '{CMD[$4]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | \
grep -v "./" | \
column -c3 -s " " -t | \
sort -nr | nl |  head -n 5
 1  1364  17,1206%    ssh
 2  928   11,648%     ll
 3  885   11,1083%    ping
 4  786   9,8657%     vi
 5  522   6,55203%    git
 

Interesting.. the original version worked fine on osx with zsh for me, this version produces bad output:

     1  4962  49.6051%
     2  851   8.50745%   -m
     3  154   1.53954%   |
     4  122   1.21963%   .
     5  86    0.859742%  -rd
 
 
     1  138  13.8%  cd
     2  97   9.7%   ls
     3  92   9.2%   git
     4  87   8.7%   exit
     5  57   5.7%   xsetwacom

Weird. Not what I expected. I guess I use windowed stuff more than I realise.

 
 
     1  328  32.8%  git
     2  137  13.7%  cd
     3  136  13.6%  ls
     4  90   9%     crea-password.rb
     5  40   4%     bzr

BTW, if you are wondering what "crea-password.rb" is, it is a script of mine that generates random (but repeatable) passwords. Note also the co-presence of the "competitors" git and bazaar ;-)

 

For me:

     1  942  11.2116%    gst
     2  477  5.67722%    ras
     3  461  5.48679%    exit
     4  456  5.42728%    gacp
     5  432  5.14163%    cd

gst: Git status
ras: rails s -b 0.0.0.0
exit: Exiting the terminal :)
gacp: git add . && git ci && git push (I'm lazy)
cd: No need for explanation

 
1   1896  18.0297%     mix
2   1166  11.0879%     gco
3   1101  10.4698%     vi
4   707   6.72309%     gl
5   565   5.37277%     git
  • mix: build tool used with Elixir
  • gco: git checkout
  • vi: editor
  • gl: git pull
  • git: generic git command
 
 1  152  15.2%  cd
 2  123  12.3%  l
 3  75   7.5%   clear
 4  70   7%     git
 5  66   6.6%   cl
 6  62   6.2%   scrapy
 7  55   5.5%   ls
 8  47   4.7%   python
 9  45   4.5%   vim
10  37   3.7%   tree
 

Does not appear to work for BASH 5, as I just get a list of dates. I wonder if the author is on macOS, and is using the pre-installed BASH 3.

Changing the $2 to $4 fixed it for me.

     1  100  10%   git
     2  76   7.6%  ls
     3  41   4.1%  cd
     4  37   3.7%  list.sh
     5  37   3.7%  emacsclient

list.sh is a script I wrote to quickly search my calibre library for books in a particular series. e.g., list.sh Justice League shows me all the "Justice League" comics I currently have.


Also, if sudo is in your top 5, then I think there's something wrong with the way you're working. Nobody should need sudo that much.

 

My tests were on zsh here.
I think you are right about the usage of sudo. I made some sudoers changes after I saw sudo in my own top list. I think for me it was there, because I used it a lot for package updating / installing.

 

On my work Mac:

     1  143  28.6%  git
     2  68   13.6%  vi
     3  52   10.4%  shore-site
     4  46   9.2%   cd
     5  39   7.8%   rg

(shore-site is a part of a development environment suite my company uses internally, basically a fancy-pants way of controlling docker instances)

On my nearest VPS:

     1  135  13.5%  sudo
     2  115  11.5%  tmux
     3  107  10.7%  cd
     4  105  10.5%  ls
     5  74   7.4%   vi

This stuff is quite hard to compare, because

  • I live in Vim and you don't get to see the commands I run from there
  • remote servers have a lot hidden behind sudo
  • I have multiple terminal sessions open at any one time on the same machine but don't share history between them

Also I'm betting things like head and grep get used a lot more than this reports but won't show up because they're fed from a pipe.

 

Hmm.., I should use terminal shortcut for clear screen...

     1  1798  17.9477%     clear
     2  1513  15.1028%     ls
     3  1297  12.9467%     git
     4  948   9.46297%     cd
     5  464   4.63166%     vim

 

I clear my terminal all the time too, but I use cmd + K to do it. Try it out, you might find it easier!

 
     1  2588  24.1869%     git
     2  730   6.82243%     k
     3  702   6.56075%     cd
     4  570   5.3271%      cat
     5  540   5.04673%     vim

git:
k: kubectl
cd:
cat:
vim:

Hmmm, I'm actually pretty surprised that docker is not there :D

 

This version work for OSX fish-shell (github.com/fish-shell/fish-shell)

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

My commands:

     1  403  35.3819%    git
     2  81   7.1115%     cd
     3  67   5.88235%    vi
     4  63   5.53117%    ssh
     5  58   5.09219%    grep
 

I cheated and used Excel because the different commands people shared to get totals didn't take into account command line arguments.

1  304  4.7904%    make lint    Run linting in my project
2  272  4.2862%    dcup         Alias for `docker-compose up`
3  196  3.0886%    gst          Alias for `git status`
4  173  2.7261%    wn pears     Alias for `workon pears`, which is using python virtualenvwrapper
5  138  2.1746%    gco develop  Alias for git checkout develop
6  121  1.9067%    dka && dcc   Alias for killing all running docker containers and then removing them
 

The one that's by far most overused (though it won't show up on the list) is the UP arrow. I will shamelessly hit UP 20 times rather than type the simplest command...

Work Computer:

     1  3212  19.8076%     git                                                                       
     2  1589  9.79896%     bosh                                                                      
     3  1279  7.88727%     cd                                                                        
     4  1126  6.94376%     ls                                                                        
     5  1078  6.64776%     vim  

Bosh being our product.

Personal Computer:

     1  55  15.896%    sudo
     2  36  10.4046%   git
     3  21  6.06936%   connect
     4  18  5.20231%   rake
     5  16  4.62428%   rvm

As you can tell from the numbers, it's really new (just a few weeks).

connect is an alias for my office's vpn.

 
 

On my hackintosh, where I've been consistently working on a fairly large-scale adonis application. This is about the output I expected to see, actually...

     1  1993  19.926%    git
     2  995   9.94801%   cd
     3  705   7.04859%   yarn
     4  487   4.86903%   adonis
     5  404   4.03919%   ls

Likewise on my server where I have ~25 docker containers running various services, no surprises here:

     1  282  28.2%  docker
     2  167  16.7%  ls
     3  131  13.1%  cd
     4  113  11.3%  docker-compose
     5  86   8.6%   sudo
 

Work box:

 1  242  48.4%  git
 2  105  21%    brew
 3  58   11.6%  cd
 4  26   5.2%   open
 5  12   2.4%   which

It's a Mac obviously (brew), most of my work done in Visual Studio for Mac. Hence "open" ... open . so I can open a project file.

Funny that ls isn't on there. I guess I know where most of my stuff is? (but not which one is in the path first, hence which ;P.)

 

This is from when I ssh to my server from windows.

     1  357  35.7%  sudo
     2  159  15.9%  cd
     3  114  11.4%  screen
     4  66   6.6%   dir
     5  62   6.2%   ls
     6  18   1.8%   nano

I'm a bit surpriced I don't see anyone else using screen. Though it doesn't look like this includes the commands from inside screen.

 
     1  135  26,9461%   npm
     2  55   10,978%    node
     3  48   9,58084%   fortune
     4  39   7,78443%   cd
     5  22   4,39122%   ls
 

fortune -o is one of my ❤ commands. From the man page if anyone is interested:

     -o    Choose only from potentially offensive aphorisms.  Please, please,
           please request a potentially offensive fortune if and only if you
           believe, deep down in your heart, that you are willing to be of-
           fended.  (And that if you are, you'll just quit using -o rather
           than give us grief about it, okay?)
 
 
     1  144  28.8%  fossil
     2  64   12.8%  curl
     3  57   11.4%  cd
     4  49   9.8%   ls
     5  25   5%     exit

Hm. The statistic is realistic, but why my history is so short?...

 

New-ish computer, but lots of git going on!

     1  792  35.2627%    git
     2  196  8.72663%    ls
     3  180  8.01425%    cd
     4  129  5.74354%    code
     5  105  4.67498%    ..
 
history | \
awk '{CMD[$4]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | \
grep -v "./" | \
column -c3 -s " " -t | \
sort -nr | nl |  head -n 10
     1  478  9.83944%    yay
     2  412  8.48086%    vim
     3  286  5.8872%     ls
     4  263  5.41375%    sudo
     5  257  5.29024%    kubectl

Though this is more representative of which commands I use more uniquely, as I only save new commands into my history, as to not crowd it too much

 
    $ history|awk '{print $2}'|sort|uniq -c|sort -rn|head -5
       176 git
        86 ack
        70 exit
        34 prove
        29 vi

exit will be because I'm constantly creating and destroying virtual terminals in GNU screen. ack is like grep but better. prove runs my tests. vi is so far down the list because most of my work is in a single vim that has been running for [looks at process table] three months now.

 

Fish shell doesn't seem to record this info :(. I'm pretty sure my top 5 commands would be

git
php
cd
rg (ripgrep)
nvim (neovim)

Edit: Completely forgot timew (Time Warrior) I use this constantly for tracking time.

 
1   2066  17.3468%     git
2   1919  16.1125%     npm
3   572   4.80269%     docker
4   468   3.92947%     sh
5   418   3.50966%     ll    

seems I'm boring, aha

 

Is sh linked to bash, dash or is it real sh? I wouldn't really see a reason to use sh, even for sh scripts

 

maybe it's my bad habit, I use sh xxx.sh instead of ./xxx.sh

 

Recently, I was doing a Python and a Django tutorial and also reading Obey the testing goat.

     1  452  23.4318%    vim
     2  218  11.3012%    ls
     3  161  8.34629%    python
     4  156  8.08709%    python3
     5  127  6.58372%    git
 
1   186  24.8663%   sudo
2   107  14.3048%   conda
3   94   12.5668%   docker
4   73   9.75936%   cd
5   44   5.88235%   ls
 
 1  216  21.6%  git
 2  152  15.2%  cd
 3  132  13.2%  ls
 4  88   8.8%   exit
 5  48   4.8%   sudo
 6  33   3.3%   ssh
 7  22   2.2%   more
 8  19   1.9%   touch
 9  16   1.6%   wmctrl
10  16   1.6%   twee2
 

For me, these are the top 5. I don't do much on my Ubuntu server.

1  203  20.3%  cd
2  200  20%    ls
3  136  13.6%  nano
4  127  12.7%  service
5  38   3.8%   tail
 


1 1094 27.7032% clear
2 916 23.1957% git
3 406 10.2811% cd
4 293 7.4196% ls
5 190 4.81134% npm

 
     1  94  18.8%  yarn
     2  81  16.2%  cd
     3  66  13.2%  gulp
     4  23  4.6%   python3
     5  22  4.4%   npm
 

I guess mine is pretty standard

1 186 18.6% cd
2 113 11.3% sudo
3 107 10.7% ls
4 101 10.1% clear
5 73 7.3% exit

 

I guess you use an IDE or don't code (probably the first one)

 

Yeah I'am mostly on eclipse. I use terminal for server deployments and ant builds mostly. ERP developer on custom java framework :)

 
     1  3015  28.0283%     git
     2  600   5.57776%     curl
     3  536   4.9828%      cd
     4  451   4.19262%     less
     5  319   2.96551%     npm
 
  1 147  29.4%  git
  2 64   12.8%  cd
  3 43   8.6%   vagrant
  4 40   8%     vi
  5 36   7.2%   ssh
 
1   1442  14.4214%   git
2   1442  14.4214%   cd
3   1129  11.2911%   psql
4   976   9.76098%   php
5   891   8.91089%   ssh
 

Neat:

     1  730  22.9127%    sudo
     2  341  10.7031%    tmux
     3  330  10.3578%    cd
     4  244  7.65851%    cargo
     5  182  5.71249%    git

I don't know what I expected.

 
     1  167  33.4%  docker
     2  62   12.4%  ssh
     3  53   10.6%  git
     4  52   10.4%  cd
     5  50   10%    ls
 
1  135  27%    git
2  106  21.2%  cd
3  73   14.6%  docker
4  43   8.6%   ls
5  27   5.4%   exit
 
     1  659  16.0146%    ls
     2  648  15.7473%    docker
     3  468  11.373%     cd
     4  406  9.86634%    clear
     5  344  8.35966%    git
 
 1  1639  16.0419%     kubectl
 2  958   9.37653%     git
 3  885   8.66203%     cd
 4  821   8.03563%     vi
 5  691   6.76324%     sudo
 

I imagine my kubectl usage was insane not too long ago. Probably still goes through spurts where it is at the top.

 

Seeing kubectl in my own top 5 and so many others, I am starting to think wether there are some shortcomings in the way we interact with k8s today...

 
     1  419  41.9%  yarn
     2  174  17.4%  git
     3  69   6.9%   NODE_ENV=vendor
     4  51   5.1%   npm
     5  40   4%     sudo
 
 1  669  66.9%  git
 2  134  13.4%  cd
 3  93   9.3%   composer
 4  31   3.1%   yarn
 5  15   1.5%   sudo
 
     1  750  16.1152%    git
     2  553  11.8823%    cd
     3  428  9.19639%    ls
     4  137  2.9437%     sudo
     5  127  2.72884%    python
 
 1  336  33.6%  ls
 2  247  24.7%  git
 3  116  11.6%  vim
 4  106  10.6%  cd
 5  82   8.2%   clear
 
 1  1379  16.9161%    git
 2  790   9.69087%    npm
 3  783   9.605%      yarn
 4  525   6.44014%    push
 5  373   4.57556%    gca
 
 1  209  10.7676%    git
 2  164  8.44925%    sudo
 3  135  6.95518%    cd
 4  117  6.02782%    vi
 5  96   4.9459%     ssh
 
     1  2690  26.857%      git
     2  1520  15.1757%     cd
     3  1155  11.5315%     ls
     4  622   6.21006%     pipenv
     5  385   3.84385%     pytest

oh! Interesting..

 

I love the tldr command: github.com/tldr-pages/tldr even though is not in my top commands (thankfully) it's still a great tool imo.

 
 1  447  19.3256%    docker
 2  296  12.7972%    git
 3  214  9.25205%    ls
 4  196  8.47384%    cd
 5  169  7.30653%    nvim
 
     1  130  13%    cd
     2  120  12%    sudo
     3  116  11.6%  ls
     4  104  10.4%  git
     5  81   8.1%   vim
 
     1  301  52.439%    python3
     2  66   11.4983%   ls
     3  54   9.40767%   cd
     4  29   5.05226%   .
     5  22   3.83275%   git
 

For me:

     1  163  32.6%  git
     2  78   15.6%  ls
     3  72   14.4%  rsync
     4  65   13%    cd
     5  30   6%     vi

cd + ls is harmonious couple.

 
     1  126  9.13706%    wp
     2  90   6.52647%    reload
     3  85   6.16389%    npm
     4  83   6.01885%    brew
     5  70   5.07614%    ssh
 
 
 

New machine, but actually I'm very surprised with these.

1   193  19.3%  sudo
2   86   8.6%   valet
3   78   7.8%   git
4   49   4.9%   ll
5   44   4.4%   cd
 
     1  1721  28.2548%    git
     2  429   7.04318%    back
     3  407   6.68199%    serve
     4  393   6.45214%    front
     5  358   5.87752%    yarn
 

Docker compose :D

 1  151  15.1%  docker-compose
 2  97   9.7%   npm
 3  89   8.9%   ls
 4  75   7.5%   cd
 5  65   6.5%   ssh
 

My top 5

 1  46  18.3267%   clear
 2  44  17.5299%   sudo
 3  28  11.1554%   git
 4  21  8.36653%   cd
 5  19  7.56972%   heroku
 

sudo
grep
git
cd
ls

In order of thrilling results 🤣.

 

J'aime jouer avec les commandes, mais je n'arrive à obtenir ce que je veux reelement :devenir un bon programmeur

 

Hey Amadou.
I am sorry, my french is pretty terrible. I read out it did not work for you?

 
 
 
 1  395  16.9966%    docker-compose
 2  262  11.2737%    l
 3  245  10.5422%    cd
 4  176  7.57315%    git
 5  173  7.44406%    sudo
code of conduct - report abuse