If it is a cloud server, check to see if there is daily automatic backup. If so, just roll back. Otherwise, there is basically no way to save the day, so you must be extremely careful when operating the server.
On Linux Please do not delete things Please do not delete things Please do not delete things Back up files before modifying them:
cp yourfile{,`date +"%Y%m%d"`}
If you want to delete a file:
mv yourfile{,bak}
There is only one type of file that can be deleted: useless log files There is only one type of file that can be deleted: useless log files There is only one type of file that can be deleted: useless log files
Method 1: When a process opens a file, as long as the process keeps the file open, even if it is deleted, it still exists on the disk. This means , the process does not know that the file has been deleted, it can still read and write to the file descriptor provided to it when it was opened. The file is not visible except to the process because it has been Removed its corresponding directory index node.
View deleted but still open files: sudo lsof|grep deleted For example, return:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 3000 www-data 2w REG 251,0 15284 287237 /var/log/apache2/error.log.1 (deleted)
apache2 3000 www-data 7w REG 251,0 576513 287219 /var/log/apache2/access.log.1 (deleted)
3000 is the process PID, and 2 in 2w is the file descriptor (FD) of error.log.1 of the deleted file. For example, you can see it by executing the following command:
Method 2: Be extra careful when using rm. After accidentally deleting, it is best to unmount the partition in time to avoid data overwriting. If you must mount, Read-only mode can be used.
extundelete can be used to recover files deleted by rm on ext3 or ext4 partitions. http://extundelete.sourceforge.net/ http://www.gnutoolbox.com/extundelete/
First of all, I can tell you that there is no recycle bin
Try using testdisk to retrieve files
If it is a cloud server, check to see if there is daily automatic backup. If so, just roll back. Otherwise, there is basically no way to save the day, so you must be extremely careful when operating the server.
On Linux
Please do not delete things
Please do not delete things
Please do not delete things
Back up files before modifying them:
If you want to delete a file:
There is only one type of file that can be deleted: useless log files
There is only one type of file that can be deleted: useless log files
There is only one type of file that can be deleted: useless log files
RM is a fatal command on the server. . .
It is recommended to take a look at
safe rm
to protect important files. .Method 1:
When a process opens a file, as long as the process keeps the file open, even if it is deleted, it still exists on the disk.
This means , the process does not know that the file has been deleted, it can still read and write to the file descriptor provided to it when it was opened.
The file is not visible except to the process because it has been Removed its corresponding directory index node.
View deleted but still open files:
sudo lsof|grep deleted For example, return:
3000 is the process PID, and 2 in 2w is the file descriptor (FD) of error.log.1 of the deleted file.
For example, you can see it by executing the following command:
This file can be restored using file descriptor (fd):
Method 2:
Be extra careful when using rm.
After accidentally deleting, it is best to unmount the partition in time to avoid data overwriting.
If you must mount, Read-only mode can be used.
extundelete can be used to recover files deleted by rm on ext3 or ext4 partitions.
http://extundelete.sourceforge.net/
http://www.gnutoolbox.com/extundelete/