Loading

chmod 报错 changing permissions of 'xxx': Operation not permitted

chmod 报错 changing permissions of 'xxx': Operation not permitted

问题

  1. 使用root创建了一个子用户,在home目录下创建对应的文件夹
  2. 更改文件夹的chown时报错

解决

  1. chmod的底层实现是chattr命令,用此命的功能更为强大,甚至可以锁定文件,即使root用户也操作不了此文件。

  2. 先使用lsattr查看文件属性

    lsattr temp
    # 
    ------ia-------e----- temp
    
  3. 去掉ia属性

    chattr -ia temp
    
  4. 然后正常执行chmod或者chown

  5. 恢复ia属性

    chattr +ia temp
    
posted @ 2022-09-22 17:02  Grey_xx  阅读(2376)  评论(0)    收藏  举报