System Administration - KODI and PLEX running on the same Ubuntu host

Greetings. I have a system administration question for those that are running KODI and PLEX on the same Ubuntu host.

I am running KODI as the local front end for the media pc in my living room. Plex is running in the background on the same device, providing remote access and DVR functionality.

Everything is running perfectly, except for the ability to delete files that are created by Plex DVR in the KODI user interface.

I was previously running LIBREELEC, and both KODI and PLEX were running under the same user account. But now that I switched to Ubuntu, KODI and PLEX are running under different user accounts. I added the KODI user to the PLEX group, but unfortunately that does not provide enough permissions to delete files create by the PLEX user. The reason is because the files create by the PLEX DVR have 644 permissions. That means that only the PLEX user can delete the file, but members of the PLEX group cannot delete the file.

-rw-r--r-- 1 plex plex 1.9G Jan 12 22:01 'TVSHOW_NAME - S01E01 - EPISODE_NAME.ts'

What I have to do at this time is to delete the file in PLEX (which removes the file from the PLEX library and from disk) and delete the file from KODI (which removes the file from the KODI library). When I was running LIBREELEC, I was able to delete the file from KODI and the file would also be deleted from PLEX.

Has anyone come up with a good solution for an issue like this, other than having to constantly change permissions on the files that the PLEX DVR service is creating?

Maybe this ?:

Set the relevant group rights on the folder, and then run this:

chmod g+s /path/to/folder

Interesting… let me tinker with this and I’ll let you know how it turns out.

1 Like

This unfortunately did not work. Although the new folders were created with desired permissions, the new file was still created with the original permissions.

:~/dvr$ ls -lah TVSHOW_NAME
total 12K
drwxr-sr-x  3 plex  kodi 4.0K Jan 13 09:23  .
drwxrwsrwx 16 plex  kodi 4.0K Jan 13 09:23  ..
drwxr-sr-x  2 plex  kodi 4.0K Jan 13 09:23 Season1


:~/dvr$ ls -lah TVSHOW_NAME/Season1/
total 124M
drwxr-sr-x 2 plex kodi 4.0K Jan 13 09:23  .
drwxr-sr-x 3 plex kodi 4.0K Jan 13 09:23  ..
-rw-r--r-- 1 plex plex  124M Jan 13 09:23 'TVSHOW_NAME - SEASON1 - EPISODE_NAME.ts'

Strange, but if so, lookup ACL and maybe umask

Kodi group does not have write permissions on “Season1” or '‘TVSHOW_NAME - SEASON1 - EPISODE_NAME.ts’ only read permissions hence no deleting.

I believe, ultimately, the most frictionless solution is going to be to run both Plex Media Server and Kodi under the same account (likely your own). It’s not the only way to tackle this, but will likely require the least futzing about with ownership and permissions on your part.

It’s relatively straightforward to change the user for PMS; a systemctl edit plexmediaserver should get you started. Of course after that you’ll need to chown -R /var/lib/plexmediaserver and any other locations which PMS cares about. For Kodi, there’s likely a similar procedure.

Agreed. I was wondering if there is a way that the output file of the DVR process could be written out with 664 permission instead of 644. This should not change the security posture of the file much, and would solve this issue.

The other way would be just to run a daily cron job that runs chmod 664 on all sub-directories and files.

sudo systemctl stop plexmediaserver
sudo nano /lib/systemd/system/plexmediaserver.service
sudo systemctl daemon-reload

sudo chown -R kodi /var/lib/plexmediaserver
sudo chgrp -R kodi /var/lib/plexmediaserver

sudo systemctl start plexmediaserver

That did the trick! Thanks!

You’re welcome, glad it worked.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.