![改变所有权:“操作不允许” - 即使作为 root!](https://linux22.com/image/875990/%E6%94%B9%E5%8F%98%E6%89%80%E6%9C%89%E6%9D%83%EF%BC%9A%E2%80%9C%E6%93%8D%E4%BD%9C%E4%B8%8D%E5%85%81%E8%AE%B8%E2%80%9D%20-%20%E5%8D%B3%E4%BD%BF%E4%BD%9C%E4%B8%BA%20root%EF%BC%81.png)
我正在尝试帮助用户解决可启动 USB 驱动器的问题,但似乎有一个文件的所有权无法编辑。我以为可以通过以下方法实现:
sudo chown user:user ldlinux.sys
但是,执行该操作时,终端会出现以下错误:
Operation not permitted
我与该用户的详细聊天记录可以在这里找到这里。
答案1
该文件可能在其扩展属性中设置了不可变标志:
user@user-X550CL ~/tmp % touch immutable
user@user-X550CL ~/tmp % sudo chown root:root immutable
[sudo] password for user:
user@user-X550CL ~/tmp % sudo chattr +i immutable
user@user-X550CL ~/tmp % lsattr immutable
----i--------e-- immutable
user@user-X550CL ~/tmp % sudo chown user:user immutable
chown: changing ownership of 'immutable': Operation not permitted
要修复此问题,只需运行sudo chattr -i file
:
user@user-X550CL ~/tmp % sudo chattr -i immutable
user@user-X550CL ~/tmp % lsattr immutable
-------------e-- immutable
user@user-X550CL ~/tmp % sudo chown user:user immutable
user@user-X550CL ~/tmp %