Preface Recently our server was attacked by hackers, and the attributes of some files were modified, which made it impossible for us to delete the virus files. At the same time, we were unable to delete them using the root user. Now I’m recording the solution. Normal deletion If the file belongs to the current user, you can delete it using the rm command. rm -rf file.sh If you cannot delete it, try to delete it as root user. If you cannot delete it, please see the instructions below. Commands to know If the normal deletion method does not work, then we need to know the following command to delete lsattr The lsattr command is used to display the attributes of a file. It is used as follows # List the attributes of the file file.sh lsattr file.sh # List the attributes of all files and folders in the current directory lsattr Attribute Description
For detailed instructions, please refer to: https://baike.baidu.com/item/chattr/9841067?fr=aladdin chattr chattr is used to modify file attributes. Please switch to the root user to use this command. If you are a Ubuntu user, you can add sudo before the command to modify it. # Add i mark to the file.sh file chattr +i file.sh # Remove the i mark from the file.sh file chattr -i file.sh # Add two flags, i and a, to file.sh chattr +ia file.sh # Remove the two flags i and a from the file.sh chattr -ia file.sh For detailed operations, please refer to: https://baike.baidu.com/item/chattr/9841067?fr=aladdin Practical operation From the above, we know that when the file sets any of the attributes i and a, we cannot delete the file. So we first remove the i and a attributes, and then perform the deletion: # Remove i, a attributes chattr -ia file.sh # Check whether the removal is successful lsattr file.sh # Remove the file rm -rf file.sh If the file has not been deleted successfully, we need to consider whether the folder to which the file belongs has the i or a attribute set (this is indeed difficult to find) # Return to the previous level cd .. # Use the lsattr command directly to list the attributes of all files and folders in the current folder. # Do not use the syntax of lsattr folder, which lists the attributes of the files in the folder. If the folder is set, perform the removal operation on the folder's attributes, and then delete the files in the folder Gains
Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief discussion on the principle of js QR code scanning login
>>: Simple method to install mysql under linux
This article example shares the specific code of ...
CAST function In the previous article, we mention...
1. Rendering 2. Source code HTML < body > &...
This article describes how to add or expand a dis...
I installed node to the D drive, and I also neede...
# Installation daemon configuration for Redis on ...
GitHub address, you can star it if you like it Pl...
Table of contents 1. Email 2. Mobile phone number...
Using Nginx's proxy_cache to build a cache se...
In this article, we will analyze the production of...
Preface In order to ensure the consistency and in...
Use the following command to create a container a...
Table of contents 1. Brief Introduction 2. Run sc...
Preface In addition to the default built-in direc...
This article shares the specific code for JavaScr...