Proper way to run Plex as another user with systemd [Ubuntu Server 16.04 LTS]?

I just installed PMS on a fresh Ubuntu Server 16.04 LTS install and I would like to run Plex under a different user then ‘Plex’. Should I just edit the /lib/systemd/system/plexmediaserver.service file? And then of course chown ‘/var/lib/plexmediaserver/’. As I am new to systemd I have some concerns about this.

  1. Will the plexmediaserver.service file not be overwritten when updating PMS? As then my run as user setting would be lost.
  2. Should I only chown ‘/var/lib/plexmediaserver/’? Or are there more folders that need different ownership?
  3. Is ‘/etc/default/plexmediaserver’ not used at all and can it be ignored? As there are also configurable options in there.

Also, I noticed this error from systemd, should I be worried about that?
systemd[1]: [/lib/systemd/system/plexmediaserver.service:11] Invalid escape sequences in line, correcting: “/bin/sh -c ‘LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Media\ Server’”

  1. There is no folder called ‘/usr/lib/plexmediaserver/Plex Media Server’ is that supposed to happen?
  2. Also the folder ‘/usr/lib/plexmediaserver’ is owned by root, is that OK?

Who can clear some of this up for me? :slight_smile:

Cheers!

1 Like

use /etc/systemd/system/plexmediaserver.service.d/override.conf which is the standard method to override a service parameter.

Editing the main service file will not survive updates.

1 Like

Thanks, that’s just what I needed. For future reference as the official guide is just wrong and contains typo’s:

  • sudo service plexmediaserver stop
  • sudo chown -R myuser:myuser /var/lib/plexmediaserver
  • sudo systemctl edit plexmediaserver

This is the safe way and on Ubuntu 16.04 will create /etc/systemd/system/plexmediaserver.service.d/override.conf

[Service]
User=myuser
Group=myuser
  • sudo systemctl daemon-reload
  • sudo service plexmediaserver start
7 Likes

Thank you!! @jant90 I was searching for this for a while.
With the default setup of plex, is not easy to add an external media folder (in my case, I have an external disk with all the media).
Changing the mount of my external disk to a directory that my user is the owner and running plex with the same user, works perfect.

1 Like

Jant90,

Apologies for reviving.

What’s wrong with the official guide? What did I miss please??

1 Like

I’m sorry, I can’t exactly remember nor find the guide I was referring to. Good to see you’re looking into this though! Chances are those guides haven been updated/replaced/moved to a new location in the meanwhile as well. Also I’ve moved from Ubuntu to Arch for a while now and gotten to know systemd better as well so I’m not even sure what my actual problem was back then.

Anyways, one suggestion I could make is to always use systemctl edit instead of manually creating/editing files on any systemd distro to prevent mistakes.

1 Like

systemctl edit or an editor of your choice doesn’t prevent the user from misspelling the keywords :smiley:

Thank you for this! works great.
Official guide is broken

Which “Official guide” please?

I’m sorry, I don’t think there is an official guide to change user, or I can’t find it! Read a lot of articles, just glad this works now. Sorry if I was wrong.

I basically wanted to mount and use exfat external HDD with Plex.

I tried the fstab method, but the HDD is removable and I remove it often, and replace it with others HDDs as well.
https://support.plex.tv/articles/200288606-mounting-ntfs-drives-on-linux/ didn’t work for me (I thought exfat could work like NTFS), and fails to boot (have to read about fstab)

Then I tried https://support.plex.tv/articles/200288596-linux-permissions-guide/

But exfat doesn’t support permission for users (not Plex fault)

then I tiried Change what user Plex runs as (but that doesn’t work also)

Anyways, it would be great if you could do a write up for exFAT hdds as well. Either fstab permissions have to be changed, or Plex can be made to run as a user in Linux.

Thanks!

No problem!

I created the Linux Tips to try and cover all the important things. At some point I will finally get the time to write proper documentation and turn it in for publication & final QA.

https://forums.plex.tv/tags/server-linux-tips

1 Like