关于linux文件或文件夹删除遇到的疑问
ringa_lee
ringa_lee 2017-04-17 14:23:17
0
3
334

在/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%删除成功?

ringa_lee
ringa_lee

ringa_lee

reply all(3)
大家讲道理

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, because wendang 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.

Ty80

"But it may not be deleted" can be understood like this:

chattr +i ./wendang  #当这样时,任何用户任何权限的都不能将其删除。

To delete this file at this time, the only way is:

chattr -i ./wendang
rm -fr ./wendang

For chattr, you can go here: http://linux.51yip.com/search/chattr

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!