Plex Media Scanner --list does not return anything

I described it bellow, but after close to 14 days of no answer, made repost here, hoping there is some kind support :slight_smile:

as shown in the other thread.

sh-4.3$ cd /usr/lib/plexmediaserver/
sh-4.3$ export LD_LIBRARY_PATH=`pwd` ; ./Plex\ Media\ Scanner --list
  1: Movies
  5: Requested Movies
  4: Seasonal Movies
  7: Testing
  3: TV Shows
  2: UHD Movies
sh-4.3$ whoami
plex
sh-4.3$ 

The scanner is username sensitive because it must speak to the active, running PMS which is username plex

It still same ( i was running those commands with plex and tried with root as well, same result )

I don’t understand how your system and mine can be different. That makes no sense. I will do more digging

@ChuckPa said:
I don’t understand how your system and mine can be different. That makes no sense. I will do more digging

It is weird especially since on my plex server i dont run anything else ( just plexpy ) and its standard Ubuntu 16.04 system fully updated.

@ChuckPa here is some more info about the system

Anyone ?
Atm Iam solving the issue by URL calls and I wonder is there a way to preform
/library/sections//analyze DEEP ? with URL.

There is no known (that we Ninjas know of) URL to call. Deep Analysis runs as part of the nightly maintenance task (the butler)

@Ajki

Is the Plex Server you are having issues with the Command Line interface returning results in part of a Plex Home?

I am seeing the same results you are seeing when attempting to execute any of the Plex Scanner Command Line (vs Plex Server URL Commands) commands such as “Plex Media Scanner.exe --list”. Here is the link to my post describing my issue:

Scan/Refresh Directory via Command Line (Plex Home Server)

My Plex Server is part of a Plex Home and I think the issue has something to do with the need of an authentication token for the Plex Scanner Command Line interface similar to what is needed for the Plex Server URL Command interface. Basically, I believe all Plex Scanner Command Line calls are silently failing with “access denied” similar to the “401 Unauthorized” response on the URL Command interface if a valid X-Plex-Token is not provided.

@ChuckPa

Is there any way that you can confirm/deny my hypothesis?

You’re all forgetting one very important facet of Linux: Security

[chuck@lizum chuck]# su plex
bash-4.3$ cd /usr/lib/plexmediaserver/
bash-4.3$ export LD_LIBRARY_PATH=`pwd`
bash-4.3$ ./*Scanner --list
 11: Chuck
  9: GHI Music
 10: I-Photos
  1: Movies
  8: Music
  5: Requested Movies
  4: Seasonal Movies
 12: Test Movies
  3: TV Shows
  2: UHD Movies
bash-4.3$

@ChuckPa

Thanks for your response. I followed the steps you outlined (except su plex since I was already logged in as the user that Plex runs under (mrplex)) and received the same result as before
 nothing returned.

mrplex@HS:~$ cd /usr/lib/plexmediaserver/
mrplex@HS:/usr/lib/plexmediaserver$ export LD_LIBRARY_PATH=`pwd`
mrplex@HS:/usr/lib/plexmediaserver$ ./*Scanner --list
mrplex@HS:/usr/lib/plexmediaserver$

Here are the results of equivalent Plex Server URL command:

mrplex@HS:/usr/lib/plexmediaserver$ curl -X GET "http://127.0.0.1:32400/library/sections?X-Plex-Token=myt0ken"
<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="2" allowSync="0" identifier="com.plexapp.plugins.library" mediaTagPrefix="/system/bundle/media/flags/" mediaTagVersion="1481837967" title1="Plex Library">
<Directory allowSync="1" art="/:/resources/movie-fanart.jpg" composite="/library/sections/1/composite/1480918065" filters="1" refreshing="0" thumb="/:/resources/movie.png" key="1" type="movie" title="Movies" agent="com.plexapp.agents.imdb" scanner="Plex Movie Scanner" language="en" uuid="96977-50b-477-8a1-a3ed3f37" updatedAt="1480918065" createdAt="1478309217">
<Location id="3" path="/home/mrplex/media/movies" />
</Directory>
<Directory allowSync="1" art="/:/resources/show-fanart.jpg" composite="/library/sections/2/composite/1481083055" filters="1" refreshing="0" thumb="/:/resources/show.png" key="2" type="show" title="TV Shows" agent="com.plexapp.agents.thetvdb" scanner="Plex Series Scanner" language="en" uuid="026f1-b54-4c0-a51-f60ebe87" updatedAt="1481083055" createdAt="1481083055">
<Location id="4" path="/home/mrplex/media/tv" />
</Directory>
</MediaContainer>
mrplex@HS:/usr/lib/plexmediaserver$

Are you testing against a Plex Server that is part of a Plex Home (multiple users)? I am running on Ubuntu 16.04 LTS. What distro/version of Linux are you testing against?

Who is ‘mrplex’ ? is it the same UID as user plex ? If not, you did not do exactly as I did.

I am using the standard distribution. I do not use nor need home for the scanner commands to work as they speak to the PMS and the database directly.

The OS is Fedora 24, not that it matters, which actually uses the Ubuntu binary. The only difference is packaging.

@ChuckPa

Thanks for your response. I too am running the standard distribution installed via “sudo dpkg -i plex.deb”. The only change is that my Plex Media Server runs as a systemd service under the user mrplex (instead of the default plex). Other than the issue we are troubleshooting regarding the Plex Scanner Command Line interface, my Plex Server is working flawlessly.

[Unit]
Description=Plex Media Server for Linux
After=network.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
Environment=PLEX_MEDIA_SERVER_TMPDIR=/tmp
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 'LD_LIBRARY_PATH=/usr/lib/plexmediaserver /usr/lib/plexmediaserver/Plex\ Media\ Server'
Type=simple
User=mrplex
Group=mrplex
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

[Install]
WantedBy=multi-user.target

Fedora is a systemd service. You’ve added a unit override I see. No biggie.

I have an idea. “Spit balling” time.

In /etc/passwd, directly above mrplex, create another entry for plex, and duplicate all the other information from line mrplex.

Thought is: When the scanner does a whoami(), the name is coming back in a form it doesn’t like. Makes no sense because this page https://support.plex.tv/hc/en-us/articles/201242707-Plex-Media-Scanner-via-Command-Line works.

@ChuckPa

I tried what you said and I think I have screwed up my system. There was already a plex user in /etc/passwd (I assume created by the plex installer) that I left and created a second one above my mrplex main login user with duplicate information as my mrplex user as you suggested. Now anytime I try to execute a command needing elevated priviledges (sudo) it is asking for the password for the new plex user
which I don’t know because I didn’t create the user. Any idea what the default password of the plex user created by the plex server installer might be?

The installer script postinst does add user plex and create /var/lib/plexmediaserver (default home dir) when installing.

grep plex /etc/passwd and grep plex /etc/shadow. That will tell you what ‘plex-ish’ usernames exist.
When you examine /etc/shadow it will be junk or * (impossible password). This is deliberate because PMS does not need a ‘login account’ as a service.

to fix things up, sudo sh (just jump to root) and go edit it / clean it out as it should be. To restore absolute security to any username, use * in the password field. To make fully open (not advised) make it a null field (::)

@ChuckPa

Thanks for your quick response. When trying to issue sudo sh, I am prompted for the following:

mrplex@HS:~/$ sudo sh
[sudo] password for plex:

This is my big problem as I don’t know the password for plex that it now thinks I am after editing /etc/passwd and duplicating the mrplex account above the real one with plex as the user name. This is the only admin account I have on the system.

Any ideas


ok


su (jump to root) from YOUR username. You must have root level access to the machine. How did you edit /etc/passwd before? Use that technique to get the root shell.

I suggest sudo because using su typically causes problems with ubuntu distributions where there is no root password ever assigned and only the ‘default user’ can gain root privs.

@ChuckPa

I am at your mercy. I originally edited the /etc/passwd via the following command logged in as the mrplex user which had sudo priveldges.

mrplex@HS:~$ sudo nano /etc/passwd

which prompted me for the mrplex password which obviously I knew. Once I edited the file by adding the new plex user (in addition to the original plex user created by the installer) with duplicate info as the mrplex account the duplcate id of 1000 is confusing the system.

plex:x:1000:1000:My Admin,,,:/home/mrplex:/bin/bash --- this is the one I added
mrplex:x:1000:1000:My Admin,,,:/home/mrplex:/bin/bash
plex:x:111:117::/var/lib/plexmediaserver:/bin/bash

Now when I issue the same command to edit /etc/passwd I am getting prompted for the plex password:

plex@HS:~$ sudo nano /etc/passwd
[sudo] password for plex:

I am a major heap of hurt right now. Hoping you can figure out how to get me out of this mess. Btw I have never logged out of my SSH session since doing this as I am afraid I can never log in again


Do you still have your ‘Live’ media (disaster recovery disk) ?

If you do, use it. This is it’s purpose. It has one user, namely root which is without password. It exists entirely in ram and will not touch your physical HD unless you tell it to install.

If you don’t have one, using either a DVD or a thumb drive (2GB is fine), create a bootable image. I find having the physical media is good. I create the thumb drive after I’m happy with it.

When you boot into the live environment, locate and mount your system’s normal root partition on the, ram-based, /mnt directory.
From there it is a simple task of using vi to edit /mnt/etc/passwd and /mnt/etc/shadow as you need. If your live media has a graphical / visual text editor included, use it if you prefer.

Fedora’s boot disk is both an installer and a live (the ‘Try’ option). It lets you do all I’ve just detailed above.