Solution to Operationnotpermitted error when deleting a file

Source: Internet
Author: User
Solution to the Operationnotpermitted error when deleting a file-Linux general technology-Linux technology and application information. for details, refer to the following. When some files are to be deleted in Linux, an error is prompted, for example, handling the Operation not permitted error prompt.

[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

The super user root is used. The system will tell you that the operation is not allowed. Is there a problem with Linux? No. if you use the lsattr command, the answer is displayed.

[Root @ linux236 root] # lsattr
--- I ----------./1.txt
--------------./Weiqi. ldif
--------------./Qi. schema

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. 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.

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.