Want to turn your Ubuntu / Debian machine into a media server, so you can watch videos stored in that machine remotely?
Here’s the step by step guide for beginners how to install the Plex media server, set it up, and fix users’ folder not accessible issue in Ubuntu & Debian Linux.
Step 1: Install Plex Media Server
Plex is available to install in Ubuntu & Debian Linux via 2 package formats: Snap that runs in sandbox and native .deb package via its official apt repository.
Option 1: Install Plex as Snap (Beginner friendly)
The snap package is quite easy to install, and has NO folder permission issue in my case in Ubuntu 22.04. Though, some users don’t like applications run in sandbox.
Ubuntu user can simply search for and install ‘Plexmediaserver’ as snap from Ubuntu Software app:
Debian and Ubuntu based system can install the Snap package by opening terminal from start menu and running command:
sudo snap install plexmediaserver --classic
Option 2: Install Plex as native .deb package
Some user prefer the classic native .deb
package format, though the installing process will be a little bit complicated that Snap.
Plex has an official repository maintains the deb packages for Debian/Ubuntu users. The official setup guide is outdated (at the moment of writing) due to new Debian policy. So, you can follow the steps below to add repository and install the package.
1. First, open terminal either from start menu or by pressing Ctrl+Alt+T
on keyboard. When terminal opens, run command to install the key:
wget -O - https://downloads.plex.tv/plex-keys/PlexSign.key | gpg --dearmor | sudo tee /usr/share/keyrings/PlexSign.gpg
The command may stuck at blinking cursor after downloading the key. You just need to type user password (no visual feedback) and hit Enter to continue to dearmor and install it.
Install wget via sudo apt install wget
if command not exist
2. Then, run command in terminal to download and install the source file:
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
3. As mentioned, the source file is outdated at the moment of writing this tutorial. You have to edit it via command:
sudo nano /etc/apt/sources.list.d/plexmediaserver.list
Then add [signed-by=/usr/share/keyrings/PlexSign.gpg] between ‘deb’ and ‘https’ link to specify the key file.
4. After saving change by pressing Ctrl+x, type y and hit Enter. You may now refresh package cache and install Plex media server as .deb
by running the commands below one by one:
sudo apt update
sudo apt install plexmediaserver
When done, it runs as a system service silently in the background. For Debian user, you may run the commands below one by one to enable, start and check the service status:
sudo systemctl enable plexmediaserver && sudo systemctl start plexmediaserver
sudo systemctl status plexmediaserver
Step 2: Configure permissions to allows access user folders
If you installed Plex via SNAP package, just SKIP this step as things should be done automatically!
For the native .deb
package, it didn’t allow me to add any personal folder under user home to library for watching remotely. And, I fixed the issue by doing the step below:
1. Add user plex
to group plex
. It created a user and a group both named plex
during the installing process. However, the user was not added into that group.
To add it, just open terminal and run command:
sudo gpasswd --add plex plex
2. Add plex
to current user group, to allow accessing the folders under current user home directory.
sudo gpasswd --add plex $USER
You may replace $USER
to another username to allow accessing contents under that user directory.
Step 3: Add your media files to Plex library
OK, now either go to localhost:32401
or localhost:32400
, or search for and launch ‘Plex Media Server’ from application launcher which also open that link automatically in browser.
Then, login either via your social account, or register via an email account (no verification required). After logged in, it pops up an ads for Plex Pass which you can simply close that dialog. Finally, it will show you the how it works screen.
Next, follow the wizard to give a name for your media server. Or leave it default for lazy men. Un-check “Allow me to access my media outside my home” option so only devices connected to home network can access, or leave default to allow access anywhere in the world.
Then, click ADD LIBRARY in next step, choose a type (movie, music, TV shows, or others) and finally browse and add your folders (e.g., / -> home -> username -> Videos
).
When done adding media folders, you may either use the link in next page to get apps or just using the web browser for accessing remotely.
Your videos or other medias should be automatically listed in the page of ‘MORE -> Server Name‘.
There you may click on the ‘+’ button to add more libraries or click editing an existing library to add more media folders.
Step 4: Access from a remote device
To access the media server in any device, either download & install a Plex App and login via the account you registered in previous step. Or, just go to https://app.plex.tv/desktop in web browser and login with that account.
(Optional) Until Plex Media Server
For the Snap package, just remove it using Ubuntu Software app or by running command below in terminal:
sudo snap remove --purge plexmediaserver
For the native .deb package, remove it by running command:
sudo apt remove --autoremove plexmediaserver
And, remove the source repository as well as key file via:
sudo rm /etc/apt/sources.list.d/plexmediaserver.list /usr/share/keyrings/PlexSign.gpg
Finally, refresh package cache via sudo apt update
to apply change.