Music Player Daemon: A quick guide.

There are many music players available on Linux and other platforms, I wrote about that earlier. One that stands out from the crowd regarding it’s architecture is Music Player Daemon (or just mpd). It follows the client server model, where the daemon is a music server and you can connect various clients to control the music playback. It’s not the easiest to set up in Ubuntu but with this small guide it should work.

The community documentation on MPD can be found here, however I find that guide rather incomplete as it leaves out some important pieces of information for installation and configuration in *buntu.

Step 0

When installing mpd it creates a daemon in /etc/init.d. This daemon is started by ‘root’ immediately after installation. It has it’s own config file. Personally I rather start mpd with my user account after login so you don’t need sudo to shutdown the daemon. Therefore I start by disabling the ‘system wide’ mpd instance:

sudo /etc/init.d/mpd stop

To permanently prevent this daemon from starting at boot*:

sudo update-rc.d -f mpd remove
Step 1 Install package(s)

To install mpd we need 2 packages, the following line will fetch and install them:

sudo apt-get install mpd mpc

mpd is the daemon of course. mpc is the most basic client. a more elaborate client is ncurses music player client ++ or ncmpcpp. This one is also in the standard repos:

sudo apt-get install ncmpcpp

Step 2 Setup .mpd folder in you home directory

Run the following commands if you are logged in to the account for which you want to setup mpd.  ~ stands for your home directory /home/yourname

mkdir -p ~/.mpd/playlists
touch ~/.mpd/mpd.db
touch ~/.mpd/mpd.log
touch ~/.mpd/pid
touch ~/.mpd/mpdstate

This will create the necessary folders and files.

Step 3 Edit config file

Now you need to create a file called .mpdconf (mpd will look for your config there) and tell mpd where to find the required files and directories. I’ll provide an example of such a config file where you can change yourname into your user name.

port                    "6600"
music_directory         "/home/yourname/Music"
playlist_directory      "/home/yourname/.mpd/playlists"
db_file                 "/home/yourname/.mpd/mpd.db"
log_file                "/home/yourname/.mpd/mpd.log"
state_file              "/home/yourname/.mpd/mpdstate"
pid_file                "/home/yourname/.mpd/pid"

audio_output {
        type    "pulse"
        name    "My PulseAudio output"

You can both create and edit the file .mdconf with nano, a text editor inside the terminal. Just remember that ctrl+c does not work to paste in nano. Use shift+insert or right click and choose paste. Of course you can use any text editor you like here, nano is just my suggestion. The line for that would be:

nano ~/.mpdconf
Step 4 Start mpd as your user-account (not root)

Once you’ve disabled the system wide daemon (step 0) you should be able to run your own instance with:

Enjoy MPD and try different clients

Once set up it is easy to install different clients from the Ubuntu repositories and see which one you like best. There is a list of various client on the community wiki page. This guide should apply to all Ubuntu derivatives and Linux Mint. The config file should work on all distros as far as I know.

* only perform this command when you want to follow my route, if you prefer to keep the system wide daemon running and work on the permissions then don’t do this.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s