21

I just installed the Plex media server from the Ubuntu Software Center, and opened the web interface. I wanted to start by adding a collection. When it gave me a file browser, I wanted to go to /home/robin/Videos. /home is as far as I got. It showed robin, with an arrow in front of it, but when I tried to expand the directory tree it was empty. The same happened when trying to access /media/Data. For me it's quite useless like this, as all of my media files are inside those 2 directories.

Help would be much appreciated.

My first guess seemed to be a correct one; It is, as always, a permissions problem. How do I give plex access to my home folder without also giving other users access to it? My home folder is encrypted by the way, so that'll probably complicate things a little.

robin@RobinJ:~$ sudo -u plex bash
[sudo] password for robin: 
bash: /home/robin/.bashrc: Permission denied
plex@RobinJ:~$ ls -al
ls: cannot open directory .: Permission denied
plex@RobinJ:~$ cd /home
plex@RobinJ:/home$ cd robin
bash: cd: robin: Permission denied
plex@RobinJ:/home$ ls -al robin
ls: cannot open directory robin: Permission denied

5 Answers 5

31

Plex is run under plex username, so you may encounter the following permission issues:

  • Ubuntu restricts access to /media/$USER through ACL (that's the "+" when you ls -l /media). Solution below.
  • Your drives may not be mounted to allow plex user to read it. Check it with ls -l on the drive or folder that cause issue, to see the group owner, group permissions and user permissions. Solution below.
  • Your folder may not allow plex user or group to read it. Use sudo chmod -R u+r FOLDER to allow all users. Or add flex user to the folder group (see below) and use sudo chmod -R g+r FOLDER.

Fix permissions to allow Plex to access /media/$USER

Check which group you and plex belong to:

groups
groups plex

Now, add plex user to your user group, and allow this group to access /media/$USER:

MYGROUP="$USER"
sudo usermod -a -G $MYGROUP plex
sudo chown $USER:$MYGROUP /media/$USER
sudo chmod 750 /media/$USER
sudo setfacl -m g:$MYGROUP:rwx /media/$USER
sudo service plexmediaserver restart

Fix permissions of NTFS partitions

NTFS partitions must be mounted with appropriate read rights in /etc/fstab:

Check your user and group id (1000 and 1000 in example):

id

Edit /etc/fstab to mount the drive with read permissions for your user group and for all users (cf. umask, which is 777 less the desired "chmod" number):

UUID="XXXXXX" /media/USERNAME/MOUNTPOINT ntfs rw,nosuid,nodev,allow_other,default_permissions,uid=1000,gid=1000,umask=002 0 0

Fix permissions of mdadm RAID disks

If you're using mdadm, this may be needed in /etc/mdadm/mdadm.conf:

CREATE mode=0775
5
  • 2
    My media folders where owner/group my username (which for some reason was stopping the thumbnails from being generated)... Once I ran usermod -a -G username plex and then sudo service plexmediaserver restart and did a "Force Refresh" the thumbnails all downloaded correctly :) Probably not the correct fix but it works. Aug 7, 2015 at 11:15
  • Thank you SOO MUCH. I have struggled with this so much and this is finally what worked.
    – chase
    Jan 4, 2016 at 6:54
  • I think adding one of the flags in /etc/fstab did it for me, spent lots of time on other solutions but this one did it for me, thanks. Dec 26, 2017 at 22:11
  • Just wanted to say this worked to me as well, have a great day !
    – Liso
    Sep 24, 2020 at 9:54
  • askubuntu.com/a/352027 I was uncomfortable with the idea of adding plex to my user group, but see the above answer to a similar (not-plex-specific) question. It works if your drives are ext4. I don't know about NTFS. Just use /media/MOUNTPOINT as that answer says instead of /media/USERNAME/MOUNTPOINT as this answer says.
    – salsbury
    Dec 20, 2020 at 6:57
3

You've got two options I think. You can run plex media server as your user, or you can add yourself and plex to a group and give that group access to your home folder. I run Plex Media Server on OS X for the time being, so I haven't run into this problem myself, but the fix should be fairly trivial. This link explains how to add users to groups in linux, that's the way I think I'll be going when I switch my Plex server to Ubuntu.

5
  • Yeah, running it as the current user does indeed solve this particular problem.
    – RobinJ
    Jun 15, 2012 at 9:15
  • But why plex can't access files. Files in home folder are readable by any user.
    – umpirsky
    Sep 20, 2012 at 18:37
  • 2
    What is strange is when I do sudo -u plex bash I can list home folder as plex user, but from plex app, it logs Error listing directory [/home/umpirsky] - boost::filesystem::status: Permission denied. How is that possible?
    – umpirsky
    Sep 20, 2012 at 19:11
  • 3
    @umpirsky This confused me too, but eventually I learned that Plex requires write permissions on the file before it will detect it. Jun 14, 2013 at 3:09
  • Plex needs READ access to every level of the directory path to where the media is located. If your content is under /mnt/md0/share/media/movies, it needs to be able to list/read all the way up/down that file path chain, not just the final folder...
    – Peter
    May 20, 2023 at 1:38
1

Add plex as a user in your group , then add root as a user in your group .

then type sudo gpasswd -a root yourusernamehere,sudo gpasswd -a plex yourusernamehere you will have to give sudo password which is your password and then run this command using your drive path , mine is /media/PLEX for my external drive input your path here where u see /media/PLEX

find /media/PLEX -type d -exec chmod 755 {} \;; find /media/PLEX -type f -exec chmod 644 {} \;

This will ultimately allow plex to use your files & folders. Hope this helps.

1
  • 3
    Why does one have to add root to the usergroup?
    – erb
    Jun 11, 2014 at 13:41
1

Try adding Plex to the plugdev group.

Open a terminal (Press ControlAltT) and enter

sudo gpasswd -a plex plugdev

Verify that plex was added to the plugdev group by entering:

groups plex

which should display what groups plex belongs too. Next, reboot the computer and start plex to verify this corrected the problem.

If just adding plex to plugdev works for you, then you are much better off than adding plex to your usergroup as suggested in other answers. That may work but it's not a great idea security wise.

3
  • Why is a restart necessary? (I haven't verified if you solution works because I don't have the privilege to be able to restart my server without considerable work)
    – erb
    Jun 11, 2014 at 13:40
  • 1
    Rebooting restarts the PMS. You can also just do sudo systemctl restart plexmediaserver Nov 11, 2018 at 22:05
  • I tried this, made no change.
    – Mark Deven
    Mar 24, 2021 at 15:31
-1
  1. Install Plex.
  2. Open terminal.
  3. Install samba - sudo apt-get install samba.
  4. From ~ do cd ... This will take you to /home.
  5. Create new plex folder in /home: sudo mkdir plex
  6. Go to new folder: cd plex
  7. Create new folder in plex/: sudo mkdir music
  8. Set permissions: sudo chmod 777 * -R
  9. Set owner if required sudo chown plex:plex -R

Do the same for other media if required, don't forget if you add new media you may need to set permissions/owner on that too.

2
  • 2
    Are you sure you have the right syntax for the chown command? Jul 9, 2012 at 2:13
  • 1
    There is no reason to install samba. It isn't even used in this example. May 5, 2018 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .