Check permissions for intermediate directories on Linux/UNIX when troubleshooting permission problems
brian_s 270002K5X3 Visits (9320)
I've seen several Linux/UNIX system administrators struggle with a scenario like this one:
A user reports to the administrator they are trying to "cd" in to a directory but keep getting permission denied:
$ cd /tmp
As the root user, the administartor checks the permissions on the directory:
# ls -ald /tmp
The administrator see's the permissions are rwxrwxrwx (777) and can't figure out why the user is getting a permission denied message when they try to CD in to the directory.
What is going on here? In order for a user to CD in to any directory on the system, they must also have at least read and execute permissions on EVERY parent directory all the way down to the root of the filesystem (/).
So in the example above the user can't access the directory because they don't have read and execute permissions on one of the parent directories.
An easy way to quickly see all the parent directory permissions is to run this one-liner as root (change the dir= to the directory you would like to check)
When I run this in this example scenario, I get this output:
And I can quickly see the reason the user can't access /tmp