岁月小筑 Exit Reader Mode

Cannot remove file (Operation not permitted)

Have you ever tried to delete a file however the system shows Operation not permitted, even if you are the root user? Here is one of the possibilities.

When I use Centos, I have ever tried to meet this situation.

I found so many methods, however none of them works for me.

Finally, I found the answer of this question: chattr.

chattr is a higher-level file attributes command, it can be only use for superuser. And lsattr is to show file attributes. For example:

You can see, the file 1.t has an “i”, it means Immutable. So we just should remove the immutable attribute, and then we can remove the file.

chattr -i 1.t

Now, you can delete the file as you want to.