ls mystery

Michael Abbott michael at araneidae.co.uk
Tue Feb 17 07:56:43 GMT 2004


> > To be precise, on a directory the "r" bit allows you to access a file
> > *if* you know its name, while the "x" bit allows you to list the files
> > in the directory.
> I'm too tired to figure out Frank's problem, but you've got this
> backwards. "r" allows reading of the directory, "x" allows access to
> files within it.

You're quite right.  I was confused by the chmod man page which says that
the x bit "allows ... search in the directory"; it really means direct
access.

So we have:
r-x	Full access
--x	Can access known files, can't list
---	Access forbidden
r--	Completely bloody useless!

My experience with r-- or rw- is that it is worthless: listing the
directory returns nothing (permission not denied, just no files listed)
and writing to the directory is also disabled.

> 	ben at yellow:/tmp$ chmod 400 x
> 	ben at yellow:/tmp$ ls -l x
> 	ls: x/y: Permission denied
> 	total 0

Now that is odd.  My experience is quite different:

	$ cd /tmp; mkdir x; touch x/y
	$ chmod 400 x
	$ ls -al x
	$

Listing the directory returns nothing at all.  I've tested this on FreeBSD
4.9 and 4.5 with the same result; interestingly, on Linux and sun3
machines I get your result, ls: x/y: Permission denied.




More information about the Ukfreebsd mailing list