views:

308

answers:

3

I'm deploying nutch. At first I just left the index file under /root/nutch1.0. This works fine when run from command line. However, when I search from web, it always returns 0 hit.

I finally found the reason: It's because the index file is located under /root that causes the failure to open the file. Things returned to normal when I move the index file to another directory.

But my question is:

I didn't change the permissions of the index file (just cp xxx another-directory). Why did the access rights change?

drwxr-x--- 12 root root    4096 Jun  1 14:49 root
drwxr-xr-x 14 root root    4096 Nov 16  2007 usr

I put files under /usr and it worked.

A: 

Because you can't access anything in the root directory unless you're root.

Look at the permissions on /root, it should be something like 700... the execute bit is set so than only root can "execute" the directory. Execution permissions on a directory are what allow you to look at files inside the directory.

It's the same reason you can't "ls /root" while you're logged in as someone else.

Dietrich Epp
the root permissions as follows:drwxr-x--- 12 root root 4096 Jun 1 14:49 root
Shore
@Shore: Is that from "ls -ld /root" ?
Eddie
right.But I'm not sure what that means exactly
Shore
That means the directory has read/write/execute for user "root", read/execute for users in group "root", and nothing for anyone else. AKA 750.
Adam Jaskiewicz
+1  A: 

To read a file, you need search ('x') permission on the directory the file is in, as well as read permission on the file itself. Moving the file from a directory where the web server does not have search permissions to one where it does will cause the effect you see.

Chris Dodd
drwxr-x---Does this mean:for user itself,read,write,execute allowedfor user in the same group,read,execute allowedfor other users,none allowed?
Shore
@Shore Yes, that's what it means.
Adam Jaskiewicz
So,to read a file,should have "ALL" execute permissions of parent directories,besides the read permission of the file itself?
Shore
yes, exactly.....
Chris Dodd
A: 

Presumably you're in group "root", and therefore can use the directory. When using a web interface, you're likely in a program with its own user (in the Unix/Linux sense), which is probably not in group "root". From the permissions you've listed, anybody can use the "/usr" directory.

David Thornley