在/home/user1目录下有下面2个文件
dr-xr-xr-x 2 root root 4096 ju1 18 23:29 wendang1
drw-rw-r— 2 user1 user1 4096 jul 18 23:22 wendang
我用user1账号登陆到此目录
rm -rf wendang1 //删除成功
rm -rf wendang //提示 rm: cannot chdir from ‘.’ to ‘wendang’ : permission denied
第二个为什么无法删除呢?
问题2:
书上有一道练习题:
当一个一般档案权限为 -rwxrwxrwx 则表示这个档案的意义为何?
答案是:任何人皆可读取、修改戒编辑、可以执行,但不一定能删除。
但不一定能删除怎么理解?什么情况下不能删除,或者说如何才能100%删除成功?
When deleting a directory, you need to delete all the files and subfolders in it first. The
-r
parameter is added for this purpose. However, becausewendang
does not have execution permission (x
), the directory cannot be entered, and The files in it cannot be deleted, so an error is reported. (The execution permission of the directory represents whether the directory can be entered)user1 does not have write permissions on the wendang’s parent directory, so the wendang directory cannot be deleted.
Deleting a file is actually a writing operation to its parent directory.
Look, in the -rwxrwxrwx operation code, there is no permission to delete at all.
"But it may not be deleted" can be understood like this:
To delete this file at this time, the only way is:
For chattr, you can go here: http://linux.51yip.com/search/chattr