Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Apache is complaining about not being able to access a file. Is there an easy way to find out what is blocking the access?

I know that I can go through the process of knowing which groups the user belongs to, checking permissions by doing an ls -ld on every folder in the path to the file, and a final ls -l on the file itself, but that's pretty tedious. Then there's also selinux and file ACLs that could also be in play.

I also know that I can change apache's login shell from /sbin/nologin to /bin/bash, then su - apache and cd through the folders until I can't, but that is also tedious.

It's something that I do often and I suspect others do as well, so I assume there's something I'm missing that makes this easier.

share|improve this question

My mistake. I would like to think the following will be more helpful.


uid=`id -u`

echo $uid

cmd='find . ! \( -user '${uid}

echo $cmd

for gid in `id -G`
    cmd=${cmd}' -o -gid '${gid}

cmd=$cmd' \)'

echo "..."
echo $cmd

for file in `find . ! \( -gid 1000 \)`
    a=$((`stat ${file} --print=%a`%10))

    if [ $a -eq 0 ] ; then
        echo $file
share|improve this answer
That finds files owned by the user in question. I want to know whether the user in question has read access to a file. They could have read access even if the file isn't owned by them by being a member of a group with read access, or alternatively they could be denied access because they don't have access to the folder that the file is in. – Greg Feb 24 '13 at 2:49

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.