% ls -l /tmp/path/to/widely/accessible/file.txt
ls: cannot access /tmp/path/to/widely/accessible/file.txt: Permission denied

Yes! This happens from time to time. And now you need to check where the problem lies. It’s not a rocket science, you have to go up a path (or down a path) and check file permissions everywhere. I’m not going to talk here about setting file permissions in Linux operating system, there are more than enough places describing this topic over the Internet. I want to talk about laziness. I’m a lazy guy and every time I stamped upon this problem I said to myself “there should be a way to display permissions along the whole path to the file”. Of course, you could write a simple one-liner but there is an actual commend to do that! check out namei:

# namei -l /tmp/path/to/widely/accessible/file.txt
f: /tmp/path/to/widely/accessible/file.txt
dr-xr-xr-x root    root    /
drwxrwxrwt root    root    tmp
drwxr-xr-x kalavan kalavan path
drw-r--r-- kalavan kalavan to
drwxr-xr-x kalavan kalavan widely
drwxr-xr-x kalavan kalavan accessible
-rw-r--r-- kalavan kalavan file.txt

Here it is! Some mean troll took out read permission from one of directories. See? Fast and efficient.

Leave a Reply