linux - rm : cannot remove: Permission denied

标签 linux bash

    max@serv$ whoami
    max
    max@serv$ ls -la ./defines.php 
    -rwxrwxrwx 1 max max 1985 2011-11-16 02:01 ./defines.php
    max@serv$ chmod 0777 ./defines.php 
    max@serv$ rm ./defines.php 
    rm: cannot remove `./defines.php': Permission denied
    max@serv$

如何删除此文件?

最佳答案

代码说明一切:

max@serv$ chmod 777 .

好吧,它并没有说明一切。

在 UNIX 和 Linux 中,删除文件的能力由该文件的访问位决定。由文件所在目录的访问位决定。

这样想——删除文件并不会修改该文件。您没有写入文件,那么为什么文件上的“w”很重要?删除文件需要编辑指向该文件的目录,因此您需要在该目录上加上“w”。

关于linux - rm : cannot remove: Permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8175697/

相关文章:

bash - 将文件的内容通过管道传输到 ls

html - Grep linux 正则表达式在 html 源代码中

linux - GDB调试时如何显示代码窗口

python - 我如何使用ansible在ubuntu上安装python 2.7.3

linux - 基于 Bash 的热重载实现

linux - 在 Linux 机器上运行 Firefox 时“无法打开共享对象文件”

linux - Bash-Command 获取当前网络带宽使用率和CPU使用率

linux - 如何在终端内完成 svn 提交过程?

linux - Crontab 正在工作,但我的脚本无法在 cron 中加载

regex - 使用正则表达式编写uCurl表数据发送到数据库的脚本