• We did not send an email asking for donations - please read this post.

Find your top 10 linux commands in your history

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
925
Reaction score
1,778
Credits
1,201
Linux is a great thing that it'll keep a history of the commands you time in the ~/.bash_history file. If you'd like to see the 10 top commands you use, you can run something like the following to see what you type out the most!

cat ~/.bash_history | sort |uniq -c|sort -nr|head -n 10

It should show something like this:
Code:
[rob ~ ]$ cat ~/.bash_history | sort |uniq -c|sort -nr|head -n 10
    223 ls
     78 cd
     57 vim domain-search.sh
     45 cd ..
     39 git status
     37 ./domain-search.sh
     25 kubectl get pods -A
     24 exit
     23 pwd
     21 git branch

The first column is the number of times it appeared, then it shows the comand typed. That gives a little info on what i've been working on .. looks like i've typed ls 223 times in my current history file! What does yours say?

Change head -n 10 to another number to get more/less than your 10 most used commands!

Edit: change your history length as well as add time/date: https://www.linux.org/threads/add-timestamp-change-history-size-in-your-linux-history.27966/
 
Last edited:


wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,786
Reaction score
6,611
Credits
28,653
nice one rob :)

here's mine from arcolinux

Code:
[[email protected] ~]$ cat ~/.bash_history | sort |uniq -c|sort -nr|head -n 10
     62 exit
     29 init 6
     23 reboot
     21 ls
     11 uname -r
      9 dmesg | grep -i swap*
      8 ls /boot
      8 cd ..
      7 du -ah
      7 df

and in the spoiler expanded to 50

[[email protected] ~]$ cat ~/.bash_history | sort |uniq -c|sort -nr|head -n 50
62 exit
29 init 6
23 reboot
21 ls
11 uname -r
9 dmesg | grep -i swap*
8 ls /boot
8 cd ..
7 du -ah
7 df
6 sudo su
6 sudo nano -m /boot/grub/custom.cfg
6 sudo dnf upgrade
6 cd Downloads
5 ./waterfox
5 sudo blkid | grep -i mjro
5 ping -c 3 google.com
5 blkid
4 sudo upd
4 sudo pacman -Syu
4 sudo dumpe2fs $(mount | grep 'on \/ ' | awk '{print $1}') | grep 'Filesystem created:'
4 sudo cat /boot/grub/custom.cfg
4 sudo apt-get clean
4 ping -c 3 linux.org
4 du -ah /var/cache/dnf/
4 du -ah /var/cache/apt/archives/
4 du -ah /var/cache/apt/archives
4 cat /boot/grub/custom.cfg
3 sudo ufw status
3 sudo rm -R 16fa2990e5014c52bbca62e8a9eb3558/
3 sudo pacman -Syy
3 sudo nano -m /etc/default/grub
3 sudo dnf clean all
3 sudo blkid | grep -i tara
3 ping -c 3 192.168.20.1
3 ping -c 3 192.168.1.1
3 iwconfig
3 ifconfig
3 du -ah /var/cache/pacman/pkg/
3 cd /var/log/journal/16fa2990e5014c52bbca62e8a9eb3558/
3 cd ~
3 apt-cache policy glibc*
2 sudo update-grub
2 sudo tune2fs -l /dev/sda4 | grep 'Filesystem created:'
2 sudo rm -R 1fa7b55a55334c05b283def41647ef23/
2 sudo parted -l
2 sudo pacman -Scc
2 sudo grub-mkconfig -o /boot/grub/grub.cfg
2 sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
2 sudo dnf install vlc

keen observers will note a mixture of commands from debian, rpm and arch - that is because the arcolinux is one of 4 distros sharing the same home.

avagudweegend

wizard
 
  • Like
Reactions: Rob

70 Tango Charlie

Well-Known Member
Joined
Oct 7, 2019
Messages
523
Reaction score
676
Credits
2,064
Mine is not near as fancy as you fellas', but here it is.
History.png


Thanks for the tip. I have it copied in my 'Terminal Commands' file.
Having lots of fun learning this Linux stuff.
OGTC
 

Ken_zh

New Member
Joined
Apr 21, 2020
Messages
8
Reaction score
0
Credits
0
Ha
This is mine

[email protected]:~$ cat ~/.bash_history | sort |uniq -c|sort -nr|head -n 10
238 exit
211 clear
124 ra
110 ls
43 python3 wechatHelper.py
37 python3
24 git status
23 python3 01.py
21 make htmldocs
19 fzf
 

rado84

Well-Known Member
Joined
Feb 25, 2019
Messages
647
Reaction score
518
Credits
3,613
Code:
     32 winecfg
     31 upd
     21 ffb
     14 resx
      8 wine WillRock.exe
      8 pakman
      7 apps
      6 ffc
      5 wine ext.exe def.scs
The most of these are aliases:
upd - alias to check for updates.
ffb - firefox backup.
resx - restart X server.
pakman - opens pacman.conf in gedit as root.
apps - open /usr/share/applications/ in the file manager as root.
ffc - deletes firefox cache.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top