Find Your Most Used Terminal Commands (Bash, Fish, Zsh)

preview_player
Показать описание
If you are the kind of Linux user that spends a lot of time in a terminal, you have probably asked yourself, "What are the commands that I run the most?" Well, using the "history" command and a few of the GNU core utilities, we can get a list of our most used commands and how many times we've run them.

WANT TO SUPPORT THE CHANNEL?

DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ

DT ON THE WEB:

FREE AND OPEN SOURCE SOFTWARE THAT I USE:

Your support is very much appreciated. Thanks, guys!
Рекомендации по теме
Комментарии
Автор

If you're an arch user you don't need to do any of this as you already know your most used command is neofetch

hiii
Автор

Most used command of an Arch user: Neofetch.
Closely followed by "Sudo Pacman -Syu"


I use Arch btw.

HungrigerWolf
Автор

Awesome! I love your videos on different terminal tools and utilities

mitchell
Автор

TheLinuxCast just posted the most dangerous commands, DT now posts the most frequently used ones 💪😎

ArniesTech
Автор

Congratulations man! You are 201k! I love your videos and love your effort for FOSS.

nullq
Автор

Saw your awk video a day or two back. And today got to see its practical use. Thanks DT for all the great videos 🙏

mohitkumar-jvbx
Автор

One liners through pipe is one of the reasons I use Linux, thanks for this one.

modrobert
Автор

I got inspired and used these tools.
Now I'm using a single file for storing more than one number in it. I mean... The tools helped!

Related idea: automatic --help.

You take an executable you've written, which can take arguments, and you add a command to it, that can scan it and present those arguments, as help instructions. If the lines that define arguments have comments, those are presented too. I did it and it was a blast!

Thank you for presenting technology like this luxurious cockpit. You defined what's on my mind many times. Unlike teachers. I'm sorry I'm annoying sometimes.

theodorealenas
Автор

Here's a quick snapshot for mine out of 245892 commands: 53599 cd, 43869 ls, 10594 vim, 8001 sudo; 6838 git, 4880 locate, ... 1799 find, ... .
I worked out mostly the same command sequence as you, but I just did this instead:
cat all_bash_history | sed -e '/ \t/d' |cut -d' ' -f1 | sort | uniq -c | sort -rh | head -n 50
It's enlightening. The reason for the sed in there is to get rid of the " cd "`printf "%b that seems to have something to do with midnight commander.

brickviking
Автор

You forgot to count commands that are "piped" into using output of other commands?

petepf
Автор

Another handy one I pinched from Bugswriter is a history search which uses fuzzy finder and can copy the selected command into the clipboard for later use:

alias h="history | cut -c 8- | sort -u | fzf +m -e | tr -d '\\n' | xclip -selection c"

I use this one all the time.

SupaShang
Автор

very useful when considering which commands to alias. Thank you!

kr
Автор

171 ls
152 cd
82 ssh
79 mutt
45 exit
28 git
27 e
20 sudo
20 rm

e being an alias to joe (using tcsh)

andreasbaumann
Автор

If you don't cut off the arguments, you can see exactly what commands you repeat often, and then you can create an alias for that specific command. I run "history | cut -f 7- -d " " | sort | uniq -c | sort | tail -20" once a week to find my most used commands with their arguments and create aliases off that list.

littlepeon
Автор

I always use spaces around pipe characters so I can just do `awk '{ print $2; }'. I just checked and my top three are `cd`, `lrt` and `exit`. With `lrt` being my shell function to acquire a list of reverse time sorted files and display only the N most recent, where the default N is 10. Of course I also have bare `ls` and my alias of `ll` in that list too which edges out `cd` even if you add in number 18 on the list, the alias `..`. Since it counts aliases, `cls` is in the top 20 as well. I guess I don't use `...` or `....` or as much as `..`, but those are handy aliases to have for changing down multiple directories. Of course it's been a slow week, so make and gcc didn't even make the top 20, although I did find `...` when I expanded to 50.

anon_y_mousse
Автор

Very similar with tcsh - which I use for historical reasons. Slight awk change.
Top of my list is'vi', an alias for neovim, where I spend most of my work time.

chrissaltmarsh
Автор

On eshell: maybe it's POSIX why it works

piotrtrzcinski
Автор

Hey DT, I don't know if you're gonna read this comment or not but when you do find the time... please review the BigLinux distro. I wanna hear your thoughts on this one. Thank you!

TurntableTV
Автор

I have HISTTIMEFORMAT set to '"%FT%T: " so my history commands look like "21476 2022-09-28T14:47:08: history". I use cut instead of awk:

history | cut -b 29- | sort | uniq -c | sort -nr | head -20

MichaelDeBusk
Автор

Waow goood video derek. Thumbs up from

josipbroztito