Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a complicated file hierarchy and I don't want to check the permissions on each directory. Is there any way to find out immediately if one file is readable by a given user? (outside of logging in as that user)

share|improve this question
up vote 9 down vote accepted

This will only work if you have root privileges

if the user has a valid login shell

su username -c 'ls /long/dir/user/filename'

if the user has a nologin shell /sbin/nologin and similar:

su username -s /bin/sh -c 'ls /long/dir/user/filename'

To find out why a user cannot access a file (builds readable output tree with permissions):

# namei -om /home/someuserhomedir/Maildir/

f: /home/someuserhomedir/Maildir/
dr-xr-xr-x root     root      /
drwxr-xr-x root     root      home
drwx------ someuser somegroup someuserhomedir
drwx------ someuser somegroup Maildir
share|improve this answer
That says Permission denied on everything, even '/'. – Oin Jan 31 '13 at 13:23
right, I was gonna suggest the ticks, it works now. Thanks! – Oin Jan 31 '13 at 13:27
If you want to figure out why you can't access a file use namei: sudo -u user namei -m /long/dir/user/filename – fuero Jan 31 '13 at 14:03
@fuero That's a good one, didn't know namei, thanks! – Martino Dino Jan 31 '13 at 22:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.