loading...
EcoLogic

What are your five most used terminal commands?

riscie profile image riscie ・1 min read

I start:

     1  1874  18.3942%     git
     2  709   6.95917%     sudo
     3  622   6.10522%     cd
     4  565   5.54574%     kubectl
     5  480   4.71143%     docker

I found this nice gem in the-book-of-secret-knowledge. (A good link for any terminal user. Have a look!)

show your top 5 most used commands including their usage %

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 -n 5

(the original was slightly modified to only show the top 5, instead of 20)

I tought it would be fun to share our most used commands here. Show me yours! ;)

❤️ Let's connect!

I would love to grow my network with other tech enthusiasts. Let's connect here or over on twitter! 👋 @langhard

Heads up

I mean I almost don't need to say this, but: Please have a close look at your commands before you share them, don't share private information!

Posted on by:

riscie profile

riscie

@riscie

dev: dotnet core, angular, typescript, linux/unix sports: disc golf live: living & loving expert

EcoLogic

EcoLogic AG. The IT company with a nimble workforce. IT with all the trimmings - just as much as you want. Tailored, down-to-earth, friendly. Get to know us!

Discussion

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
 

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

 

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.

 
 
     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.

 

Sorry to ask, but how are you guys having that dark background on your text 😯

 
 

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!

 

Be lazy and alias "clear" to just "cl" like me 🤣

 
 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
 

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.

 

Here is mine:

     1  342  17.1%  git
     2  328  16.4%  yarn
     3  216  10.8%  python
     4  190  9.5%   cd
     5  126  6.3%   ll
     6  93   4.65%  sudo
     7  57   2.85%  vue
     8  56   2.8%   rm
     9  38   1.9%   cp
    10  36   1.8%   ssh
 

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.

 
     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 ;-)

 

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
 

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
 
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   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

 

My top 20 from zsh_stats are:

     1  1016  31.4259%    git
     2  509   15.7439%    cd
     3  181   5.59852%    gulp
     4  171   5.28921%    wordmove
     5  135   4.17569%    npm
     6  116   3.588%      ls
     7  108   3.34055%    brew
     8  102   3.15496%    valet
     9  96    2.96938%    gogogo
    10  89    2.75286%    gc
    11  89    2.75286%    ga
    12  59    1.82493%    code
    13  50    1.54655%    php
    14  31    0.958862%   sudo
    15  28    0.866069%   source
    16  27    0.835138%   composer
    17  24    0.742345%   echo
    18  23    0.711414%   mysql
    19  19    0.587689%   fuck
    20  17    0.525827%   nano

gogogo is an alias for code ., and gc and ga are git commit -m and git add -A respectively.

 

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.)

 
     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?...

 

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
 
     1  1335  13.2152%     g
     2  1174  11.6215%     cd
     3  705   6.97882%     ls
     4  573   5.67214%     t
     5  568   5.62265%     nv

g = alias for git
t = alias for tig
nv = alias for nvim

and zsh_stats says:

➜ zsh_stats
     1  1335  13.2139%     g
     2  1174  11.6203%     cd
     3  705   6.97813%     ls
     4  573   5.67158%     t
     5  568   5.62209%     nv
     6  420   4.15718%     gst
     7  358   3.5435%      sudo
     8  259   2.56359%     git
     9  255   2.524%       rm
    10  181   1.79155%     gd
    11  180   1.78165%     cat
    12  154   1.5243%      tmux
    13  152   1.5045%      ag
    14  141   1.39563%     make
    15  121   1.19766%     killall
    16  119   1.17787%     mv
    17  117   1.15807%     cp
    18  112   1.10858%     find
    19  108   1.06899%     apt
    20  106   1.04919%     mkdir

gst = git status

 

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.

 

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
 
 
    $ 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.

 
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

 
     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?)
 

Is fortune the one that posts quotes to your terminal?

 
 
     1  82  21.0256%   ls
     2  76  19.4872%   cd
     3  44  11.2821%   git
     4  33  8.46154%   sudo
     5  30  7.69231%   npm

Sudo is up there because I just started to really use Ubuntu on my laptop. I had to switch after a windows update borked the system.

 

sort -nr | nl |  head -n 5
     1  1521  17.8103%    cd
     2  846   9.90632%    git
     3  737   8.62998%    ls
     4  643   7.52927%    code
     5  403   4.71897%    gaa

by the way i like it, thanks for sharing 👍 👊

 

I have no idea how python came 3rd 😶

     1  160  32%    exit
     2  112  22.4%  yarn
     3  65   13%    python
     4  35   7%     flutter
     5  26   5.2%   git

This is from my office PC.
I'll update my laptop's results later.

 
     1  367  13.5225%   nvim
     2  236  8.69565%   fg
     3  162  5.96905%   z
     4  98   3.61091%   cd
     5  94   3.46352%   la5

For those who don't have oh-my-zsh, z is a plugin that allows to quickly switch to a directory you've been to and la5 is another plugin (it stands for php artisan and comes with autocompletion). fg is for all the time I suspend nvim to quickly type a command (git push)

 
     1  290  29%    export
     2  154  15.4%  sudo
     3  151  15.1%  bash
     4  88   8.8%   find
     5  81   8.1%   python3
     6  81   8.1%   git
     7  75   7.5%   cd
     8  33   3.3%   source
     9  7    0.7%   npm
    10  6    0.6%   poweroff
 

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%    ..
 

main work is on windows but work on a vagrant vm too

----- Windows ConEmu bash -------
 1  73  14.7475%   docker
 2  54  10.9091%   exit
 3  40  8.08081%   git
 4  32  6.46465%   clear
 5  28  5.65657%   cd
----- Vagrant VM ----
 1  42  25.7669%   sudo
 2  24  14.7239%   docker
 3  12  7.36196%   ll
 4  10  6.13497%   exit
 5  10  6.13497%   clear
 
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
 
     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  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  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
 

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.

 

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 :)

 

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  533  19.2697%    ls
     2  494  17.8597%    cd
     3  488  17.6428%    git
     4  236  8.53218%    sudo
     5  124  4.48301%    rails

seems i am a ls hacker :o

 
  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  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  94  18.8%  yarn
     2  81  16.2%  cd
     3  66  13.2%  gulp
     4  23  4.6%   python3
     5  22  4.4%   npm
 


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  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
 
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
 

One year of coding produces this.

     1  6432  63.8856%     git
     2  655   6.50576%     ionic
     3  294   2.92014%     npm
     4  279   2.77116%     ls
     5  240   2.38379%     adb
 
     1  1260  57.3509%    git
     2  273   12.426%     cd
     3  250   11.3792%    npm
     4  125   5.68958%    atom
     5  59    2.68548%    docker
 
     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