DEV Community

riscie for EcoLogic

Posted on

What are your five most used terminal commands?

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!

Top comments (98)

Collapse
 
chrismoeller profile image
Christoph Möller

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
Collapse
 
vunamhung profile image
Vũ Nam Hưng

Use this for easy zsh_stats

Collapse
 
willvincent profile image
Will Vincent

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
Collapse
 
sabatesduran profile image
Dídac • Edited

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

Collapse
 
mellen profile image
Matt Ellen
     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.

Collapse
 
masesisaac profile image
Isaac Maseruka

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

Collapse
 
mellen profile image
Matt Ellen

```bash
Text goes here
```

Thread Thread
 
masesisaac profile image
Isaac Maseruka

Thanks Matt 😃

Collapse
 
yechielk profile image
Yechiel Kalmenson • Edited

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.

Collapse
 
mellen profile image
Matt Ellen

re: up arrow
Same

Collapse
 
csaratakij profile image
Chatchai Saratakij

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

Collapse
 
sbrownbourne profile image
Stephen Brown-Bourne

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

Collapse
 
diegotoral profile image
Diego Toral

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

Collapse
 
moopet profile image
Ben Sinclair

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.

Collapse
 
devmount profile image
Andreas

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
Collapse
 
pinotattari profile image
Riccardo Bernardini
     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 ;-)

Collapse
 
epicserve profile image
Brent O'Connor

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
Collapse
 
orrpeles profile image
orrpeles
 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
Collapse
 
hmphu profile image
Phu Hoang

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
Collapse
 
goodevilgenius profile image
Dan Jones

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.

Collapse
 
riscie profile image
riscie

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.

Collapse
 
yordiverkroost profile image
Yordi Verkroost • Edited
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
Collapse
 
mitchartemis profile image
Mitch Stanley • Edited

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.

Collapse
 
gatheringrays profile image
GatheringRays

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
Collapse
 
fennecdjay profile image
Jérémie Astor

Someone else using nano!