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

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.

On Ubuntu, Debian or Linux Mint:

$ sudo apt-get install cmus

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

$ sudo yum install cmus

On CentOS, first enable Repoforge repository, and then run:

$ sudo yum install cmus

On Archlinux:

$ 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

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:

  • x to play or replay a track
  • c to pause
  • b to play the next track
  • z to play the previous track
  • s to activate the shuffle

With that, you should be ready to start!

Basic Usage

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

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.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.

Adrien Brochard

I am a Linux aficionado from France. After trying multiple distributions, I finally settled for Archlinux. But I am always trying to improve my system by stacking up tips and tricks.

Latest posts by Adrien Brochard (see all)

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

  1. I use the mpd daemon to play and manage music, and the ncmpcpp ncurses-based front end to control mpd. I'll often use the pure command-line tool mpc to start/stop the music. (I used to use the GUI gmpc, until I discovered ncmpcpp).

  2. Technically, this is a GUI. If you want 'command line' try something like ffplay which is part of the ffmpeg suite or mplayer.

    • the best term I've seen for apps like this would be TUI -- Terminal User Interface. (As opposed to applications which would require a full raster graphics stack.)

  3. cmus is great stuff. Supposedly it will run on hardware as slow as Pentiums, possibly earlier, without skipping. I forget where I heard that.

  4. Title is misleading. It's hardly dealing with how to manage your music. More like how to play your music on console player rather than how to organize your music library, mass tagging, correcting metadata info etc.

    • Here's why I use cmus.

      Cmus is incredibly fast. Cmus can be controlled from the keyboard at lightning speed. Cmus's filters allow you to search for music in ways that I haven't ever seen up for offer in a GUI app. And finally, my biggest reason for using cmus: I know it won't edit the metadata of any of my tracks.

      So let me ask you: why would I want to use anything else? What would be my real world use case for something bloated and devoid of features like Rhythmbox?

  5. I used cmus for a while, before moving onto mpd.
    Gui music players look pretty, provide lots of information like artist and album info and similar artists and the like. But sometimes you just want something simple in a terminal that doesn't hog resources or crash occasionally.
    Mpd just meets my needs presently, a client/server architecture player, with the server side keeping a database of you music collection and various client controllers like mpc (command line) ncmpcpp (similar to cmus) or the graphical like gmpc, ario, sonata and cantata.

    For tagging and organising, Beets is quite nice. It's not a player, although it does have a version of mpc included, it's not as full featured. Beets checks you music tags against musicbrainz and builds a database which you can update against to pick up updates.

  6. Thanks, I've been trying to switch from Moc to Cmus for a long time but I couldn't figure out how to save and load separate playlists until I saw this post. Cmus is great.

  7. I would go with 'mpd' (as mentioned by others in the article comments). You can use command line to drive it or connect remotely from another PC/Tablet via an App. This remote connection can be command line too, or you can use MPDroid (on Android) and have a GUI. There is 'Gnome Music Player' for a GUI client on Linux.

    Offers best of both worlds...

Leave a comment

Your email address will not be published. Required fields are marked *