Most Used CLI commands in 2024
Inspired by Chris DeLuca’s post about his most used command line commands, I did a little digging into my shell history and crunched some numbers.
While checking the ZSH history of my desktop, I noticed that it only contained entries starting in May 1, 2024. It seems I had deleted the history file before that for unknown reasons or it’s related to the set history size, but at least this will give some insight.
What’s in my ZSH history
Before we dive into anything else, let’s take a look at our shell history. By exploring its contents, we can get a better idea of what we’re working with:
: 1735587928:0;vim config.toml
: 1735588935:0;git add .
: 1735588948:0;git commit -m'no hardcoded texts in templates'
: 1735588952:0;git push origin mainThere is some useful information in there. We’ve got the Epoch, which tells us when each command was executed, the exit status, and the actual commands themselves.
I tweaked the copy of the .zhistory file to include only the commands and their parameters, keeping only those that were in 2024.
Identifying the Top 10 Most Used Commands
The numbers were extracted roughly as follows:
cat history-crop | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 10This resulted in the following statistics
1180 git
1012 cd
678 vim
535 mv
425 cp
353 rm
262 mkdir
255 cat
247 ll
128 sudo
vimis actually an alias fornvim.
Most used Git commands
While I was at it, I also did a quick check of the most commonly used git commands by slightly tweaking the awk command. The important thing is that you only need to filter out lines that start with the git command.
cat history-crop | awk '$1 == "git" {print $1 " " $2}' | sort | uniq -c | sort -rnThis resulted in the following statistics
500 git commit
212 git add
111 git checkout
51 git diff
48 git mv
48 git clone
32 git log
26 git push
22 git tag
19 git rmThe Takeaways
I was actually expecting slightly higher numbers, especially in regards to the git and nvim command, as I used those a lot, but it seems that the culprit for not meeting expectations is the history file size limits.
ZSH’s default history file size is limited to 10,000 lines by default, and will truncate the history to this length by deduplicating entries and removing old data.
This can be prevented by changing the size limits:
export HISTSIZE=1000000000
export SAVEHIST=$HISTSIZE
setopt EXTENDED_HISTORYBut the history size limit was not the only issue that led to lower numbers. sudo is a good example of a too-low number, because I use it regularly to update the system, but it is masked by an alias.
alias dnfu='sudo dnf update'Finally, the piped command I used to extract the numbers does not respect piped commands. This means that if you chain greps or any other command by a pipe, it will only count the first command.
Last but not least, while tinkering with this, I stumbled upon a atuin that replaces your shell history with a SQLite database, providing additional context for your commands. Also, while looking for the reason behind the numbers, I found a tool called ZSH History Analysis. Maybe I will give them both a try for the 2025 most used CLI commands edition.