You want to prohibit directory listings for a particular directory, yet still permit the files within to be accessed by name.
Solution
Use a directory that has read permission disabled, but execute permission enabled:
$ mkdir dir
$ chmod 0111 dir
$ ls -ld dir
d--x--x--x 2 smith smith 4096 Apr 2 22:04 dir/
$ ls dir
/bin/ls: dir: Permission denied
$ echo hello world > dir/secretfile
$ cd dir
$ cat secretfile
hello world
More practically, to permit only yourself to list a directory owned by you:
$ chmod 0711 dir
$ ls -ld dir
drwx--x--x 2 smith smith 4096 Apr 2 22:04 dir/
A Directory's read permission controls whether it can be listed (eg:- via ls), and the execute permission controls whether it can be entered (eg:- via c.d). Of course the super user can still access your directory anyway he/she likes
This technique is useful for websites, where listing of directories are not permitted
source Danile J Barret
No comments:
Post a Comment