![사용자 이름이 www-data인 빈 디렉터리를 삭제할 수 없는 이유는 무엇입니까? [복사]](https://linux55.com/image/63783/%EC%82%AC%EC%9A%A9%EC%9E%90%20%EC%9D%B4%EB%A6%84%EC%9D%B4%20www-data%EC%9D%B8%20%EB%B9%88%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EB%A5%BC%20%EC%82%AD%EC%A0%9C%ED%95%A0%20%EC%88%98%20%EC%97%86%EB%8A%94%20%EC%9D%B4%EC%9C%A0%EB%8A%94%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F%20%5B%EB%B3%B5%EC%82%AC%5D.png)
Test는 내용이 없는 빈 디렉터리입니다.
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
이제 사용자 이름을 루트에서 www-data로 변경합니다.
root@localhost:~# su www-data
$ rm -rf /home/test
rm: cannot remove `/home/test': Permission denied
$
test
www-data에 속한 빈 디렉터리를 삭제할 수 없는 이유는 무엇입니까 ? 루트로 로그인하면 삭제할 수 있습니다.
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:~#
답변1
상위 디렉토리에서 항목을 삭제하려면 상위 디렉토리에 쓰기 권한이 필요합니다. 귀하의 경우 이는 /home
이며 루트만이 쓰기 액세스 권한을 가지므로 루트만이 항목을 삭제할 수 있습니다.