linux - Ubuntu服务器有回收站吗?误删了某些文件,能找回来吗?
阿神
阿神 2017-04-17 14:34:05
0
5
1502

我用的某台服务器是Ubuntu14.04,现在我在里面误删了两个文件夹,导致除了一下问题。

按照正常的思路,想找回收站,从回收站中再mv回来。但是网上转了一圈,似乎都说是在 /.Trash或者/.local/xxx 这样的目录下,但是我这没有这些目录啊,貌似这是桌面版的吧?

所以请问有没有什么简单的方法能恢复回来的?

阿神
阿神

闭关修行中......

reply all(5)
刘奇

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.

Ty80

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

迷茫

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:

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:

ls -l /proc/3000/fd/2
l-wx------ 1 root root 64 2016-03-21 08:30 /proc/3000/fd/2 -> /var/log/apache2/error.log.1 (deleted)

This file can be restored using file descriptor (fd):

sudo cp -L /proc/3000/fd/2 ./error.log.1
sudo cp -L /proc/3000/fd/7 ./access.log.1

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/

基于文件恢复:
extundelete /dev/sdb1 --restore-files /etc/passwd
基于目录恢复:
extundelete /dev/sdb1 --restore-directory /var/lib/mysql
基于磁盘恢复:
extundelete /dev/sdb1 --restore-all
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!