Update 20161109 How to Recover a Deleted File in Linux.md

This commit is contained in:
Lv Feng 2016-11-18 15:13:17 +08:00 committed by GitHub
parent 203146f9cc
commit 1a61832749

View File

@ -38,34 +38,41 @@ The alias command will confirm that rm is now aliased:
][3]
Add Alias rm Command
增加 rm 别名的命令
However, this will only last during the current user session in the current shell. To make the change permanent, you will have to save it to `~/.bashrc` (some distributions may use `~/.profile` instead) as shown below:
然而,这样做只在当前用户对话的当前 shell 上有效。为了永久改变,你必须像下面展示的这样把它保存到 '~/.bashrc' 一些版本的 Linux 系统可能使用的是 '~/.profile')。
[
![Add Alias Permanently in Linux](http://www.tecmint.com/wp-content/uploads/2016/11/Add-Alias-Permanently-in-Linux.png)
![在 Linux 中永久增添别名](http://www.tecmint.com/wp-content/uploads/2016/11/Add-Alias-Permanently-in-Linux.png)
][2]
Add Alias Permanently in Linux
在 Linux 中永久增添别名
In order for the changes in `~/.bashrc` (or `~/.profile`) to take effect immediately, source the file from the current shell:
为了使在 '~/.bashrc'(或 '~/.profile')中的改变立即生效,从当前 shell 中搜索文件:
```
. ~/.bashr
```
[
![Active Alias in Linux](http://www.tecmint.com/wp-content/uploads/2016/11/Active-Alias-in-Linux.png)
![在 Linux 中激活别名](http://www.tecmint.com/wp-content/uploads/2016/11/Active-Alias-in-Linux.png)
][1]
Active Alias in Linux
在 Linux 中激活别名
### The forensics tool Foremost
### 取证工具  Foremost
Hopefully, you will be careful with your files and will only need to use this tool while recovering a lost file from an external disk or USB drive.
但愿你对于你的文件足够小心,只有需要恢复一个来自外部磁盘或 USB 设备的丢失文件时才使用这个工具。
However, if you realize you accidentally removed a file in your system and are going to panic dont. Lets take a look at foremost, a forensics tool that was designed for this kind of scenarios.
然而,当你意识到你意外的删除了系统中的一个文件并将要感到恐慌时-不用担心。让我们来看一看 Foremost 一个被设计用来处理这种状况的取证工具。
To install foremost in CentOS/RHEL 7, you will need to enable Repoforge first:
为了在 CentOS/RHEL 7 中安装 Foremost 你需要首先启用 Repoforge
```
# rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
@ -74,6 +81,7 @@ To install foremost in CentOS/RHEL 7, you will need to enable Repoforge first
```
Whereas in Debian and derivatives, just do
然而在 Debian 及其派生系统中,只需这样:
```
# aptitude install foremost
@ -81,6 +89,7 @@ Whereas in Debian and derivatives, just do
```
Once the installation has completed, lets proceed with a simple test. We will begin by removing an image file named `nosdos.jpg` from the /boot/images directory:
安装完成以后,让我们以一个简单的测试开始。我们首先删除 /boot/images 目录下一个名为 'nosdos.jpg' 的图像文件:
```
# cd images
@ -89,6 +98,7 @@ Once the installation has completed, lets proceed with a simple test. We will
```
To recover it, use foremost as follows (youll need to identify the underlying partition first  `/dev/sda1` is where `/boot` resides in this case):
为了恢复这个文件,像下面这样使用 Foremost你需要首先确认潜在分区 - 在这种情况下, '/boot' 位于 '/dev/sda1' 分区中)
```
# foremost -t jpg -i /dev/sda1 -o /home/gacanepa/rescued
@ -96,6 +106,7 @@ To recover it, use foremost as follows (youll need to identify the underlying
```
where /home/gacanepa/rescued is a directory on a separate disk keep in mind that recovering files on the same drive where the removed ones were located is not a wise move.
/home/gacanepa/rescued 是单独磁盘中的一个目录-记住恢复的文件位于和删除的文件相同的驱动中
If, during the recovery, you occupy the same disk sectors where the removed files used to be, it may not be possible to recover anything. Additionally, it is essential to stop all your activities before performing the recovery.