How to run systemctl service as user
What you can do is to make it into a "user service" by creating an mpd.service in ~/.local/share/systemd/user/ and you can enable and start the service by running the following commands without root:
$ systemctl --user enable mpd.service
$ systemctl --user start mpd.service
The service will start running as your user.
Related videos on Youtube
Comments
-
Kristoffer Nolgren 3 monthsI'm trying to get mpd running as a server. When I
ncpmpc, I see no songs. This is probably because mpd does not have access to my music folder.Here is my folder:
drwxrwxrwx 4 pi pi 4096 Jun 2 01:23 MusicHere is some of it's content
-rwxrwxrwx 1 pi pi 10624841 Jun 2 01:23 Coldplay - Adventure Of A Lifetime .mp3 drwxr-xr-x 2 pi pi 4096 Jun 2 01:19 Coldplay - The Best Songs (2016)Mpd is running as a service, I have tried running
sudo mpdbut then I get this errorsocket: Failed to bind to '0.0.0.0:6600': Address already in useI'm thinking it's because mpd is already running. I also tried this, to stop it:
sudo systemctl stop mpdbut get this, so maybe that's what stopping
sudo mpdfrom running.Warning: Stopping mpd.service, but it can still be activated by: mpd.socketThis is all a bit confusing for me. I would prefer to run mpd as a service, but don't know what the permissions has to be for that to work. And how to set them up.
-
Kristoffer Nolgren over 5 yearsWhat user should I use then? The same as the owner of the files? Pi in this case? -
Kristoffer Nolgren over 5 yearsAlso, can I just create ./local and it's subfolders if they are not there? -
yuki_is_bored over 5 years
~/.localnot~/local. In case you're not aware,~means your home folder which is/home/<username>or/home/piin this case. -
Kristoffer Nolgren over 5 yearsyeah, sorry, I meant /.local (/home/pi/local), it's not there, tried cd .local and ls -a, only folder is .ssh. -
yuki_is_bored over 5 yearsYeah, just create it if it doesn't exist.
-
Kristoffer Nolgren over 5 yearsokay and what should the content mpd.service look like? Also I tried setting the ueser to mpd for the music folder, sudo chown -R mpd Music, didn't work though.