Article Title: delete a file: Operationnotpermitted. Linux is a technology channel of the IT lab in China. Some basic categories of files including desktop applications, Linux system management, kernel research, embedded systems, and open-source systems may all look normal, but when you try to delete the files, an error will also be reported, just like below:
[Root @ linux236 root] # ls-l 1.txt
-Rw-r -- 1 root 0 Aug 5 23:00 1.txt
[Root @ linux236 root] # rm-rf 1.txt
Rm: cannot unlink '1.txt ': Operation not permitted
You are an all-around root user. The system tells you that the operation is not allowed. Is it Linux crazy? Of course not. If you use the lsattr command, the answer is provided.
The secret is completely exposed. In the lsattrcommand, this 1.txt file has an "I" attribute, so it cannot be deleted. You can use the following commands:
[Root @ linux236 root] # lsattr 1.txt
-- I -- 1.txt
[Root @ linux236 root] # chattr-I 1.txt
[Root @ linux236 root] # rm-rf 1.txt
[Root @ linux236 root] #
This attribute is used to protect important files from being deleted. Generally, the system administrator can determine whether the file can be deleted by using these commands. To add more protection to a file, run the following command:
Chattr + I filename
Command to delete the file. At the same time, such files cannot be edited or modified. Only the root user can use the chattr command. This command can be used on Linux ext2 or ext3.
Similar to Windows file systems, most files that cannot be deleted at will have their own principles. Even if you know how to delete them, you should think twice before you proceed.
Freebsd chflags
Usage: chflags [parameter] keyword File
Common keywords:
The schg file cannot be modified at all (super-user only ). Noschg ()
Sappend file? What is Sakura in the suburbs of the hot land reclamation enzyme? Ppend method (super-user only ). Nosappend ()
Why is the sunlink file inaccessible? H Division or rename (super-user only ). Nosunlink ()
The uchg file cannot be modified at all (super-user only or normal user ). Nouchg ()
Uappend file? What is Sakura in the suburbs of the hot land reclamation enzyme? (Super-user only or general user ). Uappend ()
Why cannot a uunlink file be created? H Division or rename (super-user only or normal user ). Nouunlink ()
When uchg is used for a file, the owner cannot modify or delete the file or rename the file; nouchg ()
When uappend is used for a file, the owner can only modify the file in append mode, but cannot delete or rename the file. When uunlink is used for a file, the owner can modify the file, however, you cannot delete or rename an object. Nouappend ()
When uchg is used for a directory, the owner cannot delete or rename the directory. You can modify existing files in the directory, but cannot add or rename files in the directory; when uappend is used for a directory, the owner cannot delete or rename the directory. You can modify the existing files in the directory and add files in the directory, but cannot delete or rename the files in the directory; when uunlink is used for a directory, the owner cannot delete or rename the directory. You can modify the existing files in the directory and add files to the directory, or delete or rename the files in the directory.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service