Encountered such an error under Linux:
root@instance-byqryya4:/home# rm -f 1.txt
rm: cannot remove '1.txt': Operation not permitted
You can lsattr
command 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 root
mode, then use chattr
to 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