# Linux Tips

**URL:** <https://forums.plex.tv/t/linux-tips/276247>\
**Category:** Tips, Tricks & How-Tos\
**Tags:** server-linux-tips, server-linux, tipstricks\
**Created:** [June 26, 2018, 5:11pm UTC](https://forums.plex.tv/t/linux-tips/276247 "2018-06-26T17:11:57Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [March 28, 2021, 7:54am UTC](https://forums.plex.tv/t/linux-tips/276247/22 "2021-03-28T07:54:01Z")

</div>

### Resolving permissions problems

This How-To is about finding and resolving permission issues where PMS cannot read the file(s) due to a problem somewhere in the path.

While the process is straight forward (perform `ls -la` for each directory in the pathname to the file), the process is time consuming and somewhat tedious.

This HowTo provides a basic script which you can use (change from read-test to write-test if needed) and find where user `plex` loses its permission to get to a specific file.

Consider the case of file: `/tmp/a/b/c/d/e.mp4`

### The process

#### Step 1 - Temporarily make user `plex` a viable shell user account

#### Step 2 - Copy the text below to a file (making it a script)

I’ve named this “can-read”

```auto
#!/bin/sh

if ["$1" = ""]; then
  echo usage: $0 path-to-check
  exit 1
fi

Dir="$1"
while ["$Dir" != ""]
do
  if [-r "$Dir"]; then
    echo READ: \"$Dir\"
  else
    echo FAIL: \"$Dir\"
  fi

  NewDir="$(dirname "$Dir")"
  if ["$NewDir" = "$Dir"]; then
    Dir=""
  else
    Dir="$NewDir"
  fi
done

```

Copy the script and change the **`-r`** test to **`-w`** to test for write access

#### Step 3

After making it executable, start testing pathnames with :

```auto
su -s /bin/sh plex can-read /path/to/file.ext

```

#### Example

**Check read permissions for `/tmp/a/b/c/d/e.mp4**

```auto
# su -s /bin/sh plex ./can-read /tmp/a/b/c/d/e.mp4
FAIL: "/tmp/a/b/c/d/e.mp4"
FAIL: "/tmp/a/b/c/d"
FAIL: "/tmp/a/b/c"
READ: "/tmp/a/b"
READ: "/tmp/a"
READ: "/tmp"
READ: "/"
# 

```

**Notice the fail point?**

Checking permissions using `ls -la` finds the permissions problem.

```auto
# cd /tmp/a/b
# ls -la
total 0
drwxr-xr-x. 3 chuck chuck 60 Mar 28 03:13 ./
drwxr-xr-x. 3 chuck chuck 60 Mar 28 03:13 ../
drwx------. 3 chuck chuck 60 Mar 28 03:13 c/
# 

```

#### Step 4 - Fixing the problem

We observe that, at `/tmp/a/b` , directory `c` does not permit anyone except the owner to access it.

We correct this by fixing the permissions `chmod 755 /tmp/a/b/c`

One last verification confirms everything is now correct.

```auto
# su -s /bin/sh plex ./can-read /tmp/a/b/c/d/e.mp4
READ: "/tmp/a/b/c/d/e.mp4"
READ: "/tmp/a/b/c/d"
READ: "/tmp/a/b/c"
READ: "/tmp/a/b"
READ: "/tmp/a"
READ: "/tmp"
READ: "/"
# 

```

User `plex` will now be able to access everything from `c` down.

---

_[View the full topic](https://forums.plex.tv/t/linux-tips/276247)._
