Linux file deletion prompts Operation not permitted processing method
- 2021-01-06 00:49:43
Operation not permitted is an error in deleting a file/directory. How to handle this? !
This is usually a question of permissions, such as:
1. For ordinary users with sufficient permissions, the folder may be used by other services/processes[
lsof +D /Dir/Your/Want/To/Delete/]
First execute the above command, query to call the folder process IDs, and then kill off, this time should be able to delete!
2. If you are an ordinary user and do not have permission to delete this folder, you should use the command su or sudo to delete this folder
3. If the user is root and the error is still reported, the file is likely to be locked
[root@linux ~]# lsattr YourFile ---i---------- YourFile
The lsattr command is used to see if the system has added the i attribute, such as above. This parameter can prevent a file from being deleted, renamed, linked, or written to or added to the file. This is a great help for system security. This command is also the reason why you cannot delete the file since you are a user of root
[root@linux ~]# chattr -i YourFile [root@linux ~]# lsattr YourFile [root@linux ~]#
You can then delete the file!
Note: The i attribute The chattr command is not suitable for all directories. The chattr command cannot protect the /, /dev, /tmp, /var directories. For example, in the /tmp directory, all users can create and delete their own temporary files, and root users are the same. What if the files in that directory can't be deleted even by root users?