0

How would one, in a unix-based system, give a user read access to the filenames in a folder, but no access to the files themselves?

2 Answers2

1

Just do as you say, set read access on the directory (folder) but not on the files themselves. e.g.

umask 022             # others have r-x permissions
mkdir /tmp/f
umask 027             # others have --- permissions
echo hello > /tmp/f/1
ls -la /tmp/f

gives

total 64
drwxr-xr-x   2 user  user   4096 Feb  5 21:27 .
drwxrwxrwt 370 root root   53248 Feb  5 21:27 ..
-rw-r-----   1 user  user      6 Feb  5 21:27 1

Now others can do ls /tmp/f and see the 1 file, but can not read it.

icarus
  • 17,920
0

With the read (r) bit set on the directory you are able to access the filenames of the files inside the directory, but you won't be able to access the files or cd into that directory unless the execute (x) permission is also set on the directory.

In other words: Revoke the write and execute bit on those directories (at least chmod o=r dirname).

Related:

Freddy
  • 25,565