These are the steps that I used to get Plex to work on my machine. Hope this helps some people.
STEP 1 - Create your plex media directory
In my case, I'm going to add a drive to my system. In the disks application,
I'm going to format the drive using the ntfs file system.
**This may be incorrect. I'll create a partition using ext4 I think
and try that. NTFS permissions in Ubuntu can be tricky, but the
following /etc/fstab entry works - setting user and group to plex
Once formatted, I'm going to set the Drive and Icon names to "PlexMedia"
and set the mount point to:
/media/Whatever/PlexMedia
STEP 2 - Set mount options forcing the OS to assign plex as Owner:Group
In /etc/fstab define the user:group ownership using the following fstab entry
for the mount point of the drive
Verify the OS assigned user ID number of the plex user by:
id plex
uid=999(plex) gid=999(plex) groups=999(plex),44(video),110(render),1000(yourusergroup)
** I'm not sure that plex needs to be a member of (your user) group, but I did it that way.
Once you've verified the uid and gid 999 of the plex user or plex:plex
---
sudo gedit /etc/fstab
The following line was added by the disks program when the drive was initially set up
/dev/disk/by-uuid/7C2F39413D2BD373 /media/yourusername/PlexMedia auto nosuid,nodev,nofail,
x-gvfs-show,x-gvfs-name=PlexMedia,x-gvfs-icon=PlexMedia 0 0
The next line is what I edited it to read
/dev/disk/by-id/(OS drive name) /media/yourusername/PlexMedia auto defaults,uid=999,gid=999,nodev,...etc
The underlined is what I added. The rest was created
by the disks application once defined by me. When the drive is
mounted, the fstab entry forces the OS to assign the owner and group
as the user:group 999:999 which is the plex user and plex group.
Once mounted, the plex user will be owner and any user in the
plex group will have rights to the directory (drive) as defined
by me later in this process.
STEP 3: Add your user to the plex group
use the "groups" command to list all available groups
groups
yourusername adm cdrom sudo dip plugdev lpadmin lxd sambashare plex
----
Make sure that the "plex" group is present in the list
user yourusername needs to be a member of the plex group
sudo usermod -a -G (group name) (username to be added to the group)
Always use the -a (append) option when adding a user to a
new group. If you omit the -a option, the user will be
removed from the groups not listed after the -G option.
so... sudo usermod -a -G plex yourusername
Verify that the user "yourusername" is now a member of the group "plex"
groups yourusername
yourusername : yourusername adm cdrom sudo dip plugdev lpadmin lxd sambashare plex
----
STEP 4: Set permissions to the directory and all sub-directories and files
Add recursively to all (Owner, Group, Other Users) the execute data bit
sudo chmod a+rx /media
sudo chmod a+rx /media/whatever
sudo chmod a+rx /media/whatever/PlexTest
I'm not certain why we did this to /media or to /media/yourusername.
I probably didn't need to add the execute bit to the entirety of
each directory and sub-directory. Probably just adding it to
the /media/whatever/PlexTest directory (drive) would have been
sufficient.
Rights Data bits
Read 4 4 4 4
Write 2 2 0 0
Execute 1 0 1 0
--- --- --- ---
7 6 5 4
| | | |
| | | +-- Read Only
| | +-- Read and Execute, But Not Write
| +-- Read and Write, But Not Execute
+-- Read, Write, and Execute - full access
So... to allow Owner, Group, and all others read, write, and execute
chmod 777 (file or directory name)
STEP 5: Install ufw and set rules to allow others access to plex
ufw - Uncomplicated Firewalls
sudo apt install ufw
sudo ufw status - shows status of firewall
Status: inactive
sudo ufw enable - enables ufw
sudo ufw status
Status: active
To Action From
Samba ALLOW Anywhere
22/tcp ALLOW Anywhere
Samba (v6) ALLOW Anywhere (v6)
22/tcp (v6) ALLOW Anywhere (v6)
sudo ufw allow from 192.168.1.0/24 - Allows inbound from local network
sudo ufw allow from 192.168.1.0/24 to any port 32400 - this is the plex rule that you need to add
** I'm not sure that the "to any port 32400" rule needs to be added
since I've allowed all local inbound access, but it would be needed
if the all inbound traffic rule didn't exist.
Install gufw
sudo apt install gufw (or, if needed, apt-get install gufw)
** See Understanding ufw - Uncomplicated firewall.txt for more information