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.

posted on 2019-04-18 13:32  Areon  阅读(4180)  评论(0)    收藏  举报

导航