Change User To Run Plex On Ubuntu

Change User To Run Plex On Ubuntu

1. Update etc config /etc/default/plexmediaserver

# default script for Plex Media Server

# the number of plugins that can run at the same time
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6

# ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000

# where the mediaserver should store the transcodes
export PLEX_MEDIA_SERVER_TMPDIR=/tmp

# uncomment to set it to something else
# export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"

# the user that PMS should run as, defaults to 'plex'
# note that if you change this you might need to move
# the Application Support directory to not lose your
# media library (match what is in /etc/passwd)
export PLEX_MEDIA_SERVER_USER=plex #TODO: change this

# Uncomment this to use syslog for logging instead of
# sending logs to Plex Media Server.log
# export PLEX_MEDIA_SERVER_USE_SYSLOG=true

2. Update service config /lib/systemd/system/plexmediaserver.service

[Unit]
Description=Plex Media Server
After=network.target network-online.target

[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
ExecStartPre=/bin/sh -c '/usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"'
ExecStart=/bin/sh -c '\
export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"; \
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"; \
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )"; \
export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib; \
exec "/usr/lib/plexmediaserver/Plex Media Server"'
Type=simple
# User=plex
User=nicholas
# Group=plex
Group=admin
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
SyslogIdentifier=Plex Media Server
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

3. Update directory owner

sudo chown -R nicholas:admin /var/lib/plexmediaserver

4. Restart service

sudo service plexmediaserver restart

5. Verify

ps aux | grep plex