| name | plex-media-server |
| description | Install, configure, and manage Plex Media Server. Stream your movies, TV shows, and music to any device. |
Plex Media Server
Install, configure, and manage Plex Media Server. Stream your movies, TV shows, and music to any device.
Category: home, media
API Key Required: No (Plex is free, Plex Pass optional)
What It Does
Sets up Plex Media Server so you can stream your personal media library to any device — phone, tablet, smart TV, laptop, game console. Your agent handles installation, library setup, organization, server health, and troubleshooting.
Setup
Step 1: Install Plex Media Server
Ubuntu/Debian:
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/plex.gpg
sudo apt update
sudo apt install plexmediaserver -y
Raspberry Pi (same as above, ARM supported).
Docker:
docker run -d \
--name plex \
--network host \
-e PLEX_CLAIM="claim-XXXX" \
-v /path/to/config:/config \
-v /path/to/media:/media \
plexinc/pms-docker
Get your claim token at: https://www.plex.tv/claim/
Step 2: Verify it's running
sudo systemctl status plexmediaserver
curl -s http://localhost:32400/identity
Web UI: http://YOUR_IP:32400/web
Step 3: Organize media folders
Plex expects this structure:
/media/
├── Movies/
│ └── Movie Name (2024)/
│ └── Movie Name (2024).mkv
├── TV Shows/
│ └── Show Name/
│ └── Season 01/
│ ├── Show Name - S01E01.mkv
│ └── Show Name - S01E02.mkv
├── Music/
│ └── Artist/
│ └── Album/
│ └── 01 - Track.mp3
└── Photos/
Step 4: Add libraries
Open http://YOUR_IP:32400/web, sign in with your Plex account, and add libraries pointing to each folder.
Step 5: Open firewall
sudo ufw allow 32400/tcp
Step 6: Fix permissions
sudo chown -R plex:plex /media
Agent Commands
Server status
sudo systemctl status plexmediaserver --no-pager
curl -s http://localhost:32400/identity | python3 -c "
import sys,xml.etree.ElementTree as ET
tree = ET.parse(sys.stdin)
r = tree.getroot()
print(f\"Plex {r.get('version','')} - {r.get('friendlyName','')}\")"
Library scan (refresh for new media)
curl -s "http://localhost:32400/library/sections/all/refresh?X-Plex-Token=TOKEN"
curl -s "http://localhost:32400/library/sections?X-Plex-Token=TOKEN" | python3 -c "
import sys,xml.etree.ElementTree as ET
tree = ET.parse(sys.stdin)
for d in tree.findall('.//Directory'):
print(f\"Section {d.get('key')}: {d.get('title')} ({d.get('type')}) - {d.get('totalSize',0)} items\")"
What's currently playing
curl -s "http://localhost:32400/status/sessions?X-Plex-Token=TOKEN" | python3 -c "
import sys,xml.etree.ElementTree as ET
tree = ET.parse(sys.stdin)
videos = tree.findall('.//Video')
if not videos: print('Nothing playing')
for v in videos:
user = v.find('.//User')
print(f\"{user.get('title','Unknown')} watching: {v.get('grandparentTitle','')} {v.get('title','')}\")"
Check disk space for media
df -h /media 2>/dev/null || df -h /
du -sh /media/*/ 2>/dev/null
Recently added
curl -s "http://localhost:32400/library/recentlyAdded?X-Plex-Token=TOKEN" | python3 -c "
import sys,xml.etree.ElementTree as ET
tree = ET.parse(sys.stdin)
for v in list(tree.findall('.//Video'))[:10] + list(tree.findall('.//Directory'))[:10]:
print(f\"{v.get('title','')} ({v.get('year','')})\")"
Restart Plex
sudo systemctl restart plexmediaserver
Get Plex token
The user can find their token at: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
Or from the web UI: open any media item > "Get Info" > "View XML" — the token is in the URL.
Organizing Media
Rename movie files correctly
mkdir -p "/media/Movies/Inception (2010)"
mv inception.mkv "/media/Movies/Inception (2010)/Inception (2010).mkv"
Rename TV episodes correctly
mkdir -p "/media/TV Shows/Breaking Bad/Season 01"
mv episode1.mkv "/media/TV Shows/Breaking Bad/Season 01/Breaking Bad - S01E01.mkv"
Troubleshooting
- Can't access web UI: Check
sudo ufw status, ensure port 32400 is open
- Media not appearing: Check folder permissions (
ls -la /media), run library scan
- Buffering: Check if transcoding — direct play is better. Use MP4/MKV H.264 for widest compatibility
- Remote access not working: Enable remote access in Plex settings, forward port 32400 on your router
Constraints
- Plex is free for local streaming. Plex Pass ($5/mo or $120 lifetime) adds hardware transcoding, mobile sync, skip intro
- 4K transcoding needs decent CPU or Intel QuickSync/NVIDIA GPU
- Large libraries (10TB+) may take hours for initial scan
- Requires sudo for installation and service management