Create 3 top-level directories. Create a file and a directory in each.
$ mkdir r rx x
$ touch {r,rx,x}/file
$ mkdir {r,rx,x}/dir
Apply read only, read + execute, and execute only permissions to the respective top-level directories
$ chmod ugo=r r
$ chmod ugo=rx rx
$ chmod ugo=x x
The top-level directories now have the following attributes
dr--r--r-- 3 alex alex 4096 Nov 17 18:48 r
dr-xr-xr-x 3 alex alex 4096 Nov 17 18:48 rx
d--x--x--x 3 alex alex 4096 Nov 17 18:48 x
Each directory contains the following
drwxrwxr-x 2 alex alex 4096 Nov 17 18:48 dir
-rw-rw-r-- 1 alex alex 0 Nov 17 18:48 file
We can ls
the directory. However only the name of each item, and whether it is a directory or a file. We cannot stat
any of the contained items, so no ownership, size or permissions are revealed.
$ ls -l r/
ls: cannot access 'r/dir': Permission denied
ls: cannot access 'r/file': Permission denied
total 0
d????????? ? ? ? ? ? dir
-????????? ? ? ? ? ? file
We cannot list or read any of the contained items
$ ls r/dir
ls: cannot access 'r/dir': Permission denied
$ cat r/file
cat: r/file: Permission denied
We cannot cd
into the directory
$ cd r
bash: cd: r: Permission denied
We can ls
the directory, and stat all contained items.
$ ls -l rx
total 4
drwxrwxr-x 2 alex alex 4096 Nov 17 18:48 dir
-rw-rw-r-- 1 alex alex 0 Nov 17 18:48 file
We can list or read all of the contained items
$ ls rx/dir
$ cat rx/file
We can cd
into the directory
$ cd rx
We cannot ls
the directory
$ ls -l x
ls: cannot open directory 'x': Permission denied
We can list or read the contained items, but only if we already know (or can guess) their name
$ ls x/dir
$ cat x/file
We can cd
into the directory
$ cd x
- The preceding examples were obtained on Ubuntu Linux 16.04
- Useful further reading http://unix.stackexchange.com/questions/21251/how-do-directory-permissions-in-linux-work