Discover your most used Linux commands with MUC

David Rutland
David Rutland CLI

Life with Linux is all about the command line. While it's true that there are thousands of awesome distros and dozens of beautiful desktop environments, when it comes down to it, the Linux terminal is where things actually get done.

Whether it's transferring files to your Raspberry Pi server using SCP, creating config files, or setting up your own Google Photos alternative, you will, more often than not, find yourself elbows deep in a black screen typing commands.

But do you ever wonder what commands you type most often? If we had to hazard a guess, we'd say that our most commonly used Linux command is some variant of ls - the command to list the contents of a directory - but we don't know for sure.

We're curious though, and if you, like us, are desperate to discover your top commands, along with some ancillary information, and presented in a beautiful terminal window, muc (Most Used Commands) is the terminal tool for you.

Why would you want to know your most frequently used terminal commands?

hands typing on a laptop keyboard

How about arthritis?

This may sound fatuous (it kinda is), but typing puts wear and tear on your fingers and joints, and often the command strings you use can be wordy. If you find out what commands you use most, you can create a short, easy-to-remember alias, and use that instead.

Also, data is beautiful. But until you have the data you can't do anything with it.

How to install muc on Linux

muc is written with the Rust language, and while muc is available in the AUR (Arch User Repository), it isn't included in the standard repositories for any distro. The easiest way to install it is with Cargo.

If you don't already have Rust and Cargo on your system, the devs recommend using a script to install it. Open a terminal, and enter:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 

Once that's out of the way, you can install muc with:

cargo install --git=https://github.com/nate-sys/muc

Downloading, compiling, and installing muc took under a minute on our laptop, but significantly longer on the Linux Impact Raspberry Pi server.

Use muc to reveal you most used commands

Linux terminal showing muc output with percentages and a bar graph

Once muc is installed, you can launch the program by typing:

muc

...into any terminal.

By default, muc will use your bash history for its analysis. If it can't find the file, muc may throw an error with the message, "Could not find HISTFILE environment variable. Supply the file path with the --file option".

By default, your history file is located at ~/.bash-history

To get the full path, enter:

echo $HISTFILE

Now relaunch muc with the --file option, for instance:

muc --file /path/to/your/history file

Linux Impact's most used commands

As expected our most used command was ls - accounting for more than one quarter of all commands issued. This was followed by cd, which accounted for a further fifth.

Next up was sudo, with a range of privileged commands such as apt, dpkg, and reboot.

Further down the list were further file operations, including scp, mv, and cp. This feels about right, as we tend to use the terminal in place of a file manager.

ssh is also fairly high on the list as we spend a lot of time interacting with remote machines.

Finally, we have yt-dlp for downloading streaming media, and tiv, which we use as part of a script to fetch images from a remote server and display them in a terminal in the corner of our primary workspace.

Over on the Pi, the picture was slightly different. While ls, sudo, and file operation commands still topped the list, we found a fair bit devoted to docker, nano, and various system monitoring tools.

Having satisfied our curiosity, and created various three-letter aliases for docker-compose operations, we resolved to check in with muc in a few months time to see if our usage had changed.