How to prevent mpd from starting on boot on Ubuntu 14.04

10 Apr 2016, by Pang Yan Han

mpd refers to the Music Player Daemon, whose official website is at https://www.musicpd.org/

TLDR

On the command line, run:

sudo update-rc.d mpd disable

Then make sure the following files do not exist:

~/.mpdconf
$XDG_CONFIG_HOME/mpd/mpd.conf

And we are done!

Explanation

After installing mpd via sudo apt-get install mpd, mpd starts as a service on boot under the mpd user. To prevent mpd from starting as a service on boot, we have to run:

sudo update-rc.d mpd disable

But after doing this, for some reason, mpd still runs on my machine but this time, as my user, because the ~/.mpdconf file exists. Moving it away solved the problem. Oh, in case you were thinking a sudo service mpd stop will solve the problem, it does not, because mpd is not being run as a service on startup.

Even though I found out that the issue lies with the existence of ~/.mpdconf, a glance at man mpd shows the following line:

MPD searches for a config file in $XDG_CONFIG_HOME/mpd/mpd.conf then ~/.mpdconf then /etc/mpd.conf or uses CONF_FILE.

So it seems that other than ~/.mpdconf, if $XDG_CONFIG_HOME/mpd/mpd.conf is present, it could cause mpd to start as my user as well. I moved my mpd config file over to $XDG_CONFIG_HOME/mpd/mpd.conf, rebooted my system and found that indeed that is the case. Hence these 2 files:

~/.mpdconf
$XDG_CONFIG_HOME/mpd/mpd.conf

must not be present in order to prevent mpd from starting as the user on boot.

After thoughts

I still have no idea why mpd will start as my user - I must admit that I’m too lazy to do an in depth investigation but I checked the usual suspects of:

~/.bashrc
~/.bash_profile
~/.profile
~/.zshrc
/etc/bash.bashrc
/etc/profile

and there is no trace of the string mpd in any of those files.

comments powered by Disqus