chmod Operation not permitted与解决
使用root用户登录服务器,在服务器上向配置dns服务器,准备编辑/etc/resolve.conf文件。结果发现文件是只读的,因此想利用chmod将文件改成可写的。
chmod 666 /etc/resolv.conf
chmod: changing permissions of `/etc/resolv.conf': Operation not permitted
经过搜索,发现chattr可以修改文件的属性。
lsattr /etc/resolv.conf
----i---------- /etc/resolv.conf
chattr -i /etc/resolv.conf
这样就可以修改resolve.conf文件了。
chattr的man文件中描述i属性的含义:
A file with the ‘i’ attribute cannot be modified: it cannot be deleted or
renamed, no link can be created to this file and no data can be written to the
file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capa-
bility can set or clear this attribute.
浙公网安备 33010602011771号