How to manage your music library from the command line on Linux

Last updated on August 21, 2020 by Adrien Brochard

The command line in Linux is probably one of the scariest experience for a newcomer there is. I remember spending hours back in the day trying to decode an error message in my terminal. However, it was completely worth it. If I had to pick only one reason for a newcomer to learn to deal with the command line properly today, it would probably be for the possibility to manage a music library entirely from the terminal. The software I prefer to do this is cmus, short for "C* MUsic Player" as it is written entirely in C.

cmus is a powerful music file manager with a built-in audio player. Using its ncurses based terminal interface, you can browse your music library, and play music from playlists or queues, all from the command line.

Install cmus on Linux

First, you will need to set up and install cmus as follows.

For Ubuntu, Debian or Linux Mint:

$ sudo apt-get install cmus

For Fedora:

On Fedora, first enable RPM Fusion repository, and then run:

$ sudo yum install cmus

For CentOS or RHEL:

On CentOS, first enable Repoforge, and then run:

$ sudo yum install cmus

For Arch Linux:

$ sudo pacman -S cmus

After installation, you can launch cmus simply by typing:

$ cmus

Import Music Files to cmus

The first thing to do is to import your music files into your library. This process will immediately reveal two things: that the shortcuts are inspired by vim's, and that cmus is incredibly fast. I have successfully imported over a thousand songs in less than twenty seconds! Try that with iTunes or any graphical music library software, and you will have time to make a peanut butter sandwich before it's done.

To import music files on cmus, type the following vim-like command on cmus.

:a /path/to/your/music/folder

So on Xubuntu I did:

:a /home/adrien/Music/

Then all the music files in that folder appeared sorted by artist and album instantly.

Quick Start with cmus

Before starting anything, you might want to memorize the basic shortcuts to start playing your music. That is the only downside to cmus. Unless you change them, the default shortcuts are not very intuitive, and you have to learn them. In short:

With that, you should be ready to start!

Basic Usage of cmus

The interface of cmus is composed of seven tabs, that you access by hitting the appropriate number. For example, the startup screen is the tree tab that you can access at any time by hitting 1. This tab is pretty intuitive to use: navigate though the artist on the left panel with the up and down keys, press space to see the albums for a particular artist, use the tab key to switch to right panel with the individual songs, and finally the return key to play a song.

As you can see, the bottom banner displays the name of the artist, the album, and the title of the song currently playing, as well as the timing and the volume.

The second tab is similar to the first as it just displays the list of all the songs sorted by artist.

However, the third tab is much more interesting as it displays the current playlist. To add a song from the tree view or the sorted list view to the playlist just type y over the selected song. Once you created the perfect playlist, save it with the command.

:save /path/to/playlist

and load it with:

:load /path/to/playlist

The fourth tab displays the queue. The difference between the queue and a playlist is that once a song is played from the queue, it is then removed. To add a song to the queue, do it like adding it to the playlist, but instead use the shortcut: e

The fifth tab is pretty interesting too as it is a lightweight file explorer. It can be pretty useful to read a musical file somewhere on your computer without adding it to your library. The navigation is pretty standard: move with the up and down keys, and return to enter a folder or select a file.

The sixth tab is the library filters used to dynamically create a playlist. Just as it sounds, filters actually go through your library, and only display the tracks corresponding to some criteria defined. I will go through defining your own filters later on, but cmus already comes with a few ones. To try one, just use:

:filter [name of the filter]

So for example:

:filter classical

It will hide all the tracks from your library, except the ones containing Classical in their genre tag.

Finally, last but not least, the seventh tab is the settings. In there you can define your own shortcuts and commands. I will give an example in the next section.

Advanced Usage of cmus

As promised, now that you are more familiar with the interface, I shall give you more tips to enhance your experience.

To search for anything in any tab, just use the same shortcut as in vim




to look for the next occurrence of the keyword.

To create your own filters, use the syntax:

:fset [name of the new filter]=[expression]

For example, you can find all the old rock track with:

:fset oldies=genre="Rock"&date<1970

To learn more about the expressions you can use, I invite you to dig a bit in the doc and the included filters.

To activate the replaygain for all the tracks, use the command:

:set replaygain=1

To change a shortcut to a different key, go to the settings tab and find the current binding expression. Say for example that I want to change the play shortcut from x to w, I will then scroll until the line that says:

common  x        player-play

Then hit ENTER, and change the expression to:

:bind -f common w player-stop

To conclude, I really like cmus. There is a lot more to it than the reach of this post, so you should really read the manual page when you are ready. In short, cmus is fast, easy to learn, and respects your files. If you like the idea of managing your music library from the command line, but were not convinced by cmus, I invite you to take a shot at some alternatives like MOC and PyTone which are just as good.

What do you think of cmus? Do you like it or prefer a (non)GUI alternative? Let us know in the comments.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean