The test is a directory which contains nothing, an empty directory.
root@localhost:~# ls -l /home
drwxrwxrwx 2 www-data www-data 4096 Apr 26 17:50 test
root@localhost:~# ls -l /home/test
total 0
Now I change the username from root into www-data.
root@localhost:~# su www-data
$ rm -rf /home/test
rm: cannot remove `/home/test': Permission denied
$
Why can't I remove the blank directory test
which belongs to www-data ?
It can be removed when I login in as root.
root@localhost:~# rm -rf /home/test
root@localhost:~# ls -lZ /home/test
total 0
root@localhost:~# getfacl /home/test/
getfacl: Removing leading '/' from absolute path names
# file: home/test/
# owner: www-data
# group: www-data
user::rwx
group::rwx
other::rwx
root@localhost:~# ls -al /home
total 8352
drwxr-xr-x 10 root root 4096 Apr 26 17:50 .
drwxr-xr-x 22 root root 4096 Mar 20 16:32 ..
drwxrwxrwx 2 www-data www-data 4096 Apr 26 17:50 test
root@localhost:~# ls -al /home/test
total 8
drwxrwxrwx 2 www-data www-data 4096 Apr 26 17:50 .
drwxr-xr-x 10 root root 4096 Apr 26 17:50 ..
root@localhost:~#
getenforce
andls -lZ /home/test
for us? Oh, andgetfacl /home/test/
, to be on the complete side.ls -al
(instead ofls -l
) show you? It is possible that there's still one or more hidden files OR folders inside/home/test
(starting with a dot (.
)) which need(s) root permissions to be deleted and which might inhibit the recursive deletion of the entire folder.