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)

1 Answer 1


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
  • That says Permission denied on everything, even '/'.
    – Oin
    Jan 31, 2013 at 13:23
  • right, I was gonna suggest the ticks, it works now. Thanks!
    – Oin
    Jan 31, 2013 at 13:27
  • 2
    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, 2013 at 14:03
  • @fuero That's a good one, didn't know namei, thanks! Jan 31, 2013 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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