How to Play Music from the Linux Command Line

MPD And NCMPCPP Playing Music on Linux

Playing music from the command line isn’t the right option for everyone. MPD is a command-line option for music playback that requires manual configuration. Some people will love that. It’ll drive others insane. It all depends on how you prefer to use your Linux PC.

MPD and NCMPCPP are a lightweight super combo for playing music with loads of fine-grained control direct from the command line (NCMPCPP is ncurses-based, so technically a text-based user interface).

MPD is also a service that can be accessed by a multitude of other programs that you can use to do some cool customization. It’s also accessible over the network, so you can control it with a compatible client on your phone. In this tutorial we’ll look at how to play music from the Linux terminal with MPD and NCMPCPP.

Install MPD and NCMPCPP

Both programs are available in the repositories of most distributions. If you’re on Ubuntu, they’re definitely there. Install them with apt.

Configure MPD

The default MPD configuration can be found at “/etc/mpd.conf.” You can create per-user configurations, but assuming this is a computer you alone own, you don’t really need to. Just edit the file in your favorite editor withsudo.

When you first open the configuration file, you might be intimidated. There are a ton of options there and even more documentation. That’s actually a good thing. You can use the file itself as a reference. Even still, there actually aren’t that many lines that you need to edit to get the MPD service working the way you need it to.


First, look for the music_directory option. That’s the directory where MPD will look for your music library. Set the option equal to the directory where your music is.

Next, do the same thing with the playlist_directory. This is where MPD (and NCMPCPP) will store and look for playlists.


There are a few options to change in the next section. First, find the user and group options. The defaults here are actually good. If you want to change them, you can.

The next bit deals with how you’re going to connect to MPD. You want to uncomment the bind_to_address line that’s set to a Unix socket and the port line. It should look like the example below.

Depending on the client, MPD might just start playing the second your computer starts up. If you don’t want that, uncomment and set this line:

You’re also probably going to want MPD to automatically detect and add new music that’s added to the music directory. To do so, uncomment the line here:


MPD Configuration

This next part handles where MPD will output your music. Usually, you’re going to want to use either ALSA or PulseAudio to play everything. If you want to take advantage of a visualizer, you’ll need to set up a FIFO interface too.


If you’re using ALSA, you don’t need to do anything. It’s configured by default. You can change any of the #optional values if you have something specific in mind.


Pulse is actually configured; it’s just commented out. Head down to the Pulse section and comment out the lines you need. There are a lot of additional options for Pulse, but they aren’t strictly necessary just to play music.


If you’re interested in using a visualizer (NCMPCPP has one built in.), you need to set up FIFO. There isn’t any pre-configured FIFO output in the default configuration. You can make your own, though. Base it off of this:

That’s it. You can look around some more, but now you have everything that you need.

Add MPD To Audio

MPD needs to be part of the audio user group. Add it.

Configure NCMPCPP

With MPD out of the way, you can turn your attention to NCMPCPP. Don’t worry, there isn’t nearly as much to do.

Begin by copying the default NCMPCPP configuration.

Connect To MPD

NCMPCPP Configuration

You need to connect NCMPCPP to MPD. The lines concerning that connection are commented out. Uncomment them.

Point NCMPCPP at your music directory. too.


First, set the pat to the “.fifo” file that you configured for MPD.

Also, set the name of the visualizer to match what you set for FIFO in MPD

Next, take care of some options to make sure that your visualizer stays in sync and looks good.

This last set of options is purely stylistic. They determine how your visualizer will look. Uncomment the lines and take a look at the available options. Pick what you like best.


NCMPCPP Playlist

Open a terminal and type in ncmpcpp. The player will open to a blank playlist. NCMPCPP has different panes. Each pane displays something different. They’re all mapped to the number keys, so the playlist you see is on pane 1 and is mapped to the 1 key.

The rest of the panes are as follows:

  • File Browser
  • Search
  • Music Library
  • Playlist Editor/Management
  • Tag Editor (be careful)
  • Outputs
  • Visualizer

Navigate around with the arrow keys. The Library pane lets you move deeper from “Artist” to “Album” and into individual songs with the left and right arrows.

Common Hotkeys

There are way too many hotkeys and controls to cover here. If you want to read them all, this is an excellent resource.

Here are some of the most basic ones, though.

  • Space – Add to playlist
  • Enter – Play
  • > – Next Song
  • < – Previous Song
  • s – Stop
  • p – Pause
  • o – Move to current song
  • z – Toggle Random (shuffle)
  • x – Toggle Crossfade
  • l – Display lyrics
  • S – Save laylist

Take a look around and experiment. You can’t master either of these programs in a day. As with the command line itself, the more experienced and comfortable you get, the more you’ll get out of them.

Nick Congleton Nick Congleton

Nick is a freelance tech. journalist, Linux enthusiast, and a long time PC gamer.

One comment

  1. The point of MPD is not whether it’s operated from the command line or graphically. The point is that it is a music server that can be controlled by either local or network remote clients. It’s great for what it is, and of course you can use a local command line client to control it. You can also use a graphical client like glurp, sonata, etc.

    That being said, mpd might be a little complex if you are only looking for a command line based player and aren’t looking to use it for one of the features specific to it. Of course, it is very low resource compared to a lot of graphical music players, even if you use a graphical client with it.

    There are also a couple of more conventional command line music players like cmus and MOC. They might seem less complicated to the uninitiated. They are also low resource compared to most graphical players.

Comments are closed.