Fix the lock file problem of Operation not permitted in CentOS environment

Original link: 25e4%25b8%258boperation-not-permitted%25e7%259a%2584%25e9%2594%2581%25e6%2596%2587%25e4%25bb%25b6%25e9%2597%25ae%25e9%25a2%2598

修复CentOS环境下Operation not permitted的锁文件问题


Sometimes it will be found that the file is locked, which means that it cannot be modified, cannot be deleted (rm), and cannot be granted 777 permissions.

At this point it may be because file permissions are locked, especially common in network DNS resolution and other system files.

This article takes the DNS-NS file as an example to solve a similar problem.

Error performance

  1. “rm: cannot remove ‘/etc/resolv.conf’: Operation not permitted” when rm is displayed
  2. Pagoda panel deletion, modification, permission failed
  3. Other methods to modify and delete also fail


The first is to check

 lsattr /etc/resolv.conf

If the file appears in a long list – there is also an i in it

 sudo chattr -i /etc/resolv.conf

I should be gone by now

Then you can consider changing it directly or deleting the new one. The delete command is as follows

 rm -f /etc/resolv.conf

Relevant information

Usage of chattr command: chattr [ -RVf ] [ -v version ] [ mode ] files…

+ : Add parameters to the original parameter settings.

– : Remove the parameter based on the original parameter setting.

= : Update to the specified parameter setting.

A: The atime (access time) of a file or directory cannot be modified (modified), which can effectively prevent the occurrence of I/O errors such as laptop disks.

S: hard disk I/O synchronization option, the function is similar to sync.

a: Append, after setting this parameter, you can only add data to the file, but cannot delete it. It is mostly used for the security of server log files. Only root can set this attribute.

c: that is, compresse, set whether the file is compressed and then stored. It needs to go through automatic decompression operation when reading.

d: means no dump, the setting file cannot be the backup target of the dump program.

i: The setting file cannot be deleted, renamed, linked, and cannot be written or added at the same time. The i parameter is very helpful for the security settings of the file system.

j: Journal, set this parameter so that when the file system is mounted by the mount parameter: data=ordered or data=writeback, the file will be recorded first (in the journal) when it is written. If the filesystem parameter is set to data=journal, this parameter is automatically invalid.

s: Confidentially delete files or directories, that is, all hard disk space is recovered.

u: Contrary to s, when set to u, the data content actually still exists in the disk and can be used for undeletion.

DNS modification assistant

In addition to directly changing the file, using the pagoda panel LINUX toolbox, you can also use this script

 wget --no-check-certificate '' && bash


This article is reprinted from: 25e4%25b8%258boperation-not-permitted%25e7%259a%2584%25e9%2594%2581%25e6%2596%2587%25e4%25bb%25b6%25e9%2597%25ae%25e9%25a2%2598
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.