Nextpertise a journal of interesting technical ideas . . .

Tsukae - A tool for graphing command usage

by Brent Stewart on Saturday, Mar 6, 2021

Readers may recall that six months ago I wrote about the most commonly used Linux commands. I had seen a series of articles with that title and decided to see what my most common commands were. I suggested the following as a way to pull command history and count usage.

history | awk ‘{print $2}’ | sort | uniq -c

Tsukae is a much better way to accomplish this task. It’s much simpler and can produce the output in Bar or Pie chart, or as a list. Tsukae is written by Ilya Revenko and can be cloned from GitHub.

Tsukae Demo

Installing Tsukae

Tsukae needs Go to run (apt install golang-go). Once cloned, just go into the directory and build the executable. Tsukae expects a blacklist file to be present at ~/.config/tsukae/blacklist. This may be created automatically in future releases, but I got an error when I first ran the program and so created the file myself.

git clone https://github.com/irevenko/tsukae.git  
cd tsukae  
go get -d ./...  
go build   
~~mkdir ~/.config/tsukae  
touch blacklist~~

Update! I posted an issue for the above on GitHub and the author published an update today to fix. I tested it and confirmed it resolved the issue. This is a great example of the power of GitHub - everyone contributes in whatever way they can, and all contributions are appreciated. In my case, by suggesting an improvement and helping test. It’s why I continue to recommend that everyone participate in that community. And thanks again to Ilya!

Running Tsukae

When you run Tsukae you must specify the shell, as well as the number of commands to pull. In the example below, I’ve gotten the top six bash commands.

./tsukae bash 6  
10 Most Used bash Commands  
[255] git  
[148] apt  
[148] cd  
[107] ls  
[74] hugo  
[43] nano  

Commands list cd and ls might be uninteresting. Adding those to the blacklist text file will omit them in the future.

Git is a weird command to run most often, but I tend to run it a lot to sync the blog and upload new content. I use the hugo command in development mode at the same time. Tsukae is an interesting insight into how I’m using this computer. It’s not a vital command to accomplish work, but the next time you see one of those “Top 25 Linux Command” articles you can see how closely their list matches yours.



References:
  https://github.com/irevenko/tsukae

Recent articles related to these tags:
Linux shell
Share this article:   
Tweet