Ubuntu: What permissions are required to read a sub directories size?



Question:

For example

du -hs /path/to/directory  

Is it possible for a user to determine to size of /directory but not have read permissions for /path/to


Solution:1

No, you will get a permission denied if the user is not allowed to read the directory. Example:

~$ du -hs tmp/  8,0K    tmp/  :~$ sudo chmod 000 tmp  :~$ ls -ltr  total 16  d--------- 2 rinzwind rinzwind 4096 dec  2 17:55 tmp  $ du -hs tmp/  du: cannot read directory 'tmp/': Permission denied  4,0K    tmp/  

A user does NOT need read access to the file itself.

$ cd tmp/  :~/tmp$ ls -ltr  total 4  -rw-rw-r-- 1 rinzwind rinzwind 54 dec  2 17:55 1  :~/tmp$ sudo chmod 000 1  :~/tmp$ cd ..  :~$ du -hs tmp/  8,0K    tmp/  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »