Linux has a ton of options when it comes to media players. Many of them are just as feature packed as their proprietary counterparts on other operating systems. What most Linux users don’t realize is that there are additional options that utilize one of Linux’s greatest strengths, servers. MPD(Music Player Daemon) is a lightweight server for sharing a music library both locally and over a network.

The best aspect of MPD is, by far, its flexibility. Not only does MPD allow music to be shared and played over the network, but it also allows for numerous different front end clients. These clients range from full graphical music players to minimal command line options.

Ubuntu 16.04 running MPD with the Cantata client

Installing and Configuring MPD

Installation

Installing MPD is surprisingly simple. It really is a small and simple daemon and only comes in a single package. On Ubuntu systems, run a quick update and grab the package.
$ sudo apt-get update
$ sudo apt-get install mpd
That’s really all there is to it. Ubuntu will unpack everything and start up the daemon. Of course, you probably don’t want the default configuration, so shut down the service with Systemd, so you can start working on setting it up how you like.
$ sudo systemctl stop mpd

Configuration

MPD uses a simple text configuration file. There are other ways to configure it, including user specific configs, but it’s much easier to just use the system-wide version that ships with MPD. Open it up with Vim, or your favorite editor, and start looking around.
$ sudo vim /etc/mpd.conf
The file that is included with MPD is fairly large and complete as well as well documented. A lot of the configuration has already been set to intelligent defaults, so there isn’t that much need to change things. This guide is just going to cover some of the basics, but feel free to explore a bit more.

The first option to pay attention to is probably the most important one, the music directory. The variable itself is, music_directory and accepts a directory path as a string in quotes. This is the directory where the music that MPD will serve exists. It will read that directory and any subdirectories, so there is no need to worry about folders for artists or albums getting in the way. When you’re done, it should looks something like this:
music_directory 	"/path/to/your/music/folder"
That may actually be all that you need, especially if you are just using MPD locally on you’re computer. However, there are a few more options that it would be good to get acquainted with.
playlist_directory	"/path/to/your/playlists"
The above option sets where MPD will look for and save playlists. The default alright if you don’t plan on importing too many playlists, but if you’re the type of person who imports and exports playlists between devices or from friends, it’s probably better to set this to a directory in /home.
user			"mpd"
group			"nogroup"
You can set the user and group running the MPD server if you’d like. There really isn’t much of a reason to do this on system wide configuration, but if you need to, you can. You may need to change some folders and their ownership and permissions if you do.

If you want to use MPD over the network, it should be configured to listed to listen on your computers local IP address or hostname. If you’re just using it locally, you can leave it with the default, localhost
bind_to_address		"localhost"
For further network configuration, you can assign MPD to a specific port. By default, it uses 6600, and the line in the configuration is commented. To set a specific port, uncomment the line and set the port.
port			"6600"
The last thing that you may want to do is set a password to connect. This can be done by setting the password variable.
password		"some_password"
Feel free to explore some more, but for the basics, the defaults should work. Many of the available playback options aren’t really necessary because they will be handled by the front end clients. When you’re comfortable with the configuration, save, and start MPD with Systemd.
$ sudo systemctl start mpd

Clients

There are a ton of options for MPD clients. They have been written in both GTK and Qt as well pure CLI versions. This guide is going to cover one of the most popular GUI clients, Cantata, and one of the most popular CLI clients, ncmpcpp.

Cantata

Cantata is a GUI music player similar to popular ones like Clementine. The main difference is that it uses MPD in the back end to serve music. Cantata is written in Qt with compatibility for both Qt 4 and Qt 5. It also has Ubuntu theme integration.

Installing Cantata on Ubuntu is easy. It’s available in the repositories, so you can just install with apt.
$ sudo apt-get install cantata
Once the install finishes, you can just open up Cantata. There is a GUI installer that asks you to choose between standard and single user installs. Unless there is a specific reason why you need the single user option, choose the standard. The next screen will prompt you to connect to the MPD server. It will already contain the defaults from MPD, including localhost and port 6600. Just set everything to the match the values that you configured in the MPD configuration, and hit connect. It should connect fairly quickly, and you can just complete the configuration from there.

After the configuration process, the Cantata library screen will appear and should be populated with the music and playlists that were served by MPD. That’s really all there is for setting it up. Cantata has a ton of other features to explore, and you can spend hours getting everything set the way you like.

Ncmpcpp

For users looking for a more minimalist approach, ncmpcpp offers a robust command line solution for playing music from MPD. A command line music player isn’t for everyone, but if you’re the type of person who loves tiling WMs and thinks Vim has better controls than any GUI program, ncmpcpp will probably be the best music player you’ve ever used.

Ncmpcpp is in available in Ubuntu’s repositories, so installing it is easy with Apt.
$ sudo apt-get install ncmpcpp
Now, to configure ncmpcpp, create a folder for configuration in your home directory.
$ mkdir ~/.ncmpcpp
Now cd into that directory and create the configuration file. The configuration below is very basic, but it is enough to get ncmpcpp up and running.
$ cd ~/.ncmpcpp
$ vim config

ncmpcpp_directory =         "~/.ncmpcpp"
mpd_host =                  "127.0.0.1"
mpd_port =                  "6600"	
mpd_music_dir =             "/path/to/your/music/"
Of course, make sure that all of your values match up to the way you configured them in MPD. Now, once that is done and saved, you can exit and run ncmpcpp in a terminal. When you open it up, you should see the music from the directory that you configured in MPD. Ncmpcpp has tons of controls, and it would take way too long to go through that all here.

Final Thoughts

MPD requires a bit more configuration than most other media player solutions on Linux, but it also allows a ton more flexibility, and opens up lots of streaming and networking possibilities. Though this guide focused on Ubuntu, all of the packages mentioned are available on most major distributions, and the configuration for them is no different. If you’re a Linux user who also happens to be an audiophile or really enjoys music, definitely take a look at using MPD.