Operation not permitted caused by file flags under Linux

Encountered such an error under Linux:

root@instance-byqryya4:/home# rm -f 1.txt
rm: cannot remove '1.txt': Operation not permitted

You can lsattrcommand to check whether the file is playing file flags:

root@instance-byqryya4:/home# lsattr 1.txt
----i---------e--- 1.txt

If there is an i mark on the file, it must not be deleted, and the file cannot be edited, even if you have root privileges

First, we have to enter rootmode, then use chattrto remove this tag:

root@instance-byqryya4:/home# chattr -i 1.txt
root@instance-byqryya4:/home# lsattr 1.txt
--------------e--- 1.txt

In the same way, the way to add protection to a file is to add this mark:

root@instance-byqryya4:/home# chattr +i 1.txt

Guess you like

Origin blog.csdn.net/wy_97/article/details/104669689