mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
594aa26fb6
@ -1,130 +0,0 @@
|
||||
4 Tools to Securely Delete Files from Linux
|
||||
================================================================================
|
||||
Any computer user with normal level skill set knows that any data removed from computer system can be recovered later with little bit of efforts. This is a good thing in the scenario when you have accidentally deleted your critical data. But in most cases, you don't want your private data to be recovered easily. Whenever we remove anything, the operating system deletes just the index of the particular data. It means that data is still there somewhere on the disk, this method is insecure, as any smart computer hacker can use any good data recovery tool to easily recover your deleted data. Linux users utilizes the well know “**rm**” command to remove data from their operating system, but “rm” command works in the conventional fashion. Data removed using this command can be recovered by special file recovery tools.
|
||||
|
||||
Let’s see how we can safely and completely remove files/folders from our Linux system. The methods mentioned below remove data completely so it becomes very hard for recovery tools to find traces of the actual data and recover it.
|
||||
|
||||
### Secure-Delete ###
|
||||
|
||||
Secure-Delete is a set of tools for Linux operating system and they provide advanced techniques for permanent removal of files. Once Secure-Delete has been installed on any Linux system, it provides following four commands:
|
||||
|
||||
- srm
|
||||
- smem
|
||||
- sfill
|
||||
- sswap
|
||||
|
||||
Run following command in the terminal to install it in ubuntu:
|
||||
|
||||
sudo apt-get install secure-delete
|
||||
|
||||
![secure delete](http://blog.linoxide.com/wp-content/uploads/2015/03/secure-delete.png)
|
||||
|
||||
Run following command to install it in RHEL, Fedora or Centos:
|
||||
|
||||
sudo yum install secure-delete
|
||||
|
||||
“**srm**” command works similarly to “rm” command, but instead of just deleting the file, it first overwrites it multiple times with some random data and then removes the file permanently. The syntax for this command is pretty simply, just specify the file or directory to remove and it will take care of the task.
|
||||
|
||||
sudo srm /home/aun/Documents/xueo/1.png
|
||||
|
||||
"**sfill**" checks the specified partition/directories for space marked as free or available, and then uses its algorithm to fill it up with some random data. In this way it ensures that there are no more recoverable files/folders on the partition.
|
||||
|
||||
sudo sfill /home
|
||||
|
||||
"**sswap**" command is used to securely wipe your swap partitions. Swap partition is used to store data for running programs. First of all find out your swap partition by running the following command:
|
||||
|
||||
cat /proc/swaps
|
||||
|
||||
Example output of above command is show below:
|
||||
|
||||
aun@eagle:~$ cat /proc/swaps
|
||||
Filename Type Size Used Priority
|
||||
/dev/sda5 partition 2084860 71216 -1
|
||||
|
||||
From here, you can see that swap is set to which partition, and then securely clean it by running the following command. Replace the "/dev/sda5" part with your partition name.
|
||||
|
||||
sudo sswap /dev/sda5
|
||||
|
||||
“**smem**” is used to clean the contents of memory, its true that RAM contents are cleaned when system is rebooted or powered off, but some residual traces of data still remain in the memory. This command provides secure memory cleaning, simly run smem command on the terminal.
|
||||
|
||||
smem
|
||||
|
||||
### Shred ###
|
||||
|
||||
"shred" command destroys files/folder’s contents in a way that it is impossible to recover. It keeps overwriting the files with randomly generated data patterns so in this way it becomes very hard to recover any data from them even if hackers or thief uses high level of data recovery tools/equipments. Shred is installed by default on all Linux distributions, if you want, you can find its installation path by running following command:
|
||||
|
||||
aun@eagle:~$ whereis shred
|
||||
|
||||
shred: /usr/bin/shred /usr/share/man/man1/shred.1.gz
|
||||
|
||||
Run following command to remove file using shred utility.
|
||||
|
||||
shred /home/aun/Documents/xueo/1.png
|
||||
|
||||
Run following command to securely remove any partition using shred ; Replace partition name with your desired partition.
|
||||
|
||||
shred /dev/sda5
|
||||
|
||||
Shred by default overwrites file with random contents 25 times. If you want it to overwrite file more than this, simply specify the desired number with "shred -n" option.
|
||||
|
||||
shred -n 100 filename
|
||||
|
||||
If you want to truncate and remove file after overwriting, use "shred -u" option
|
||||
|
||||
shred -u filename
|
||||
|
||||
### dd ###
|
||||
|
||||
This command is originally used for Disk Cloning. It is used to copy contents of one partition or disk to another. But it is also used for securely wiping out the contents of a hard disk or partitions. Run following command to overwrite your current data with random data.You don't need to install dd command, all Linux distributions include this command already.
|
||||
|
||||
sudo dd if=/dev/random of=/dev/sda
|
||||
|
||||
You can also overwrite the contents of hard disk or partitions by simply replacing everything with “zero”.
|
||||
|
||||
sudo dd if=/dev/zero of=/dev/sda
|
||||
|
||||
### Wipe ###
|
||||
|
||||
Wipe was originally developed to securely erase files from magnetic media. This command line utility writes special patterns to the files repeatedly. It uses fsync() call and/or the O_SYNC bit to force disk access. It uses Gutmann algorithm for repeated writes. You can remove contents of single file, folder or entire hard disk with this command, but whole hard disk format using wipe command will take good amount of time. The installation and use of this utility is pretty easy.
|
||||
|
||||
Install wipe on ubuntu by running the following command on the terminal.
|
||||
|
||||
sudo aptitude install wipe
|
||||
|
||||
![Wipe Linux](http://blog.linoxide.com/wp-content/uploads/2015/03/wipe.png)
|
||||
|
||||
Install Wipe in Redhat Linux, Centos or Fedora by running the following command:
|
||||
|
||||
sudo yum install wipe
|
||||
|
||||
Once the installation is complete, run following command on the terminal to get complete list of its available options:
|
||||
|
||||
man wipe
|
||||
|
||||
Remove any file or directory as:
|
||||
|
||||
wipe filename
|
||||
|
||||
Securely remove your tmp partition by running following command:
|
||||
|
||||
wipe -r /tmp
|
||||
|
||||
Use following command to remove contents of complete partition (replace partition name with your desired partition).
|
||||
|
||||
wipe /dev/sda1
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
We hope you find this article useful, the privacy of your data is critical, its important to have such secure file removal utilities installed on your system so you may be able to remove your private data without fear of being recovered easily. All of the above mentioned tools are pretty lightweight, they take minimum system resources to run, and does not affect performance of your system in anyway. Enjoy!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/security/delete-files-permanatly-linux/
|
||||
|
||||
作者:[Aun Raza][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunrz/
|
@ -0,0 +1,130 @@
|
||||
# Linux 下四种安全删除文件的工具 #
|
||||
|
||||
任何一个普通水平的计算机用户都知道,从计算机系统中删除的任意数据都可以稍候通过一些努力恢复出来。当你不小心删除了你的重要数据,这是一个不错的方案。但是大多数情况,你不希望你的隐私数据被轻易地恢复。不论何时,我们删除任意的文件,操作系统删除的仅仅是特定数据的索引。这就意味着,数据仍然保存在磁盘的某块地方,这种方法是不安全的,任何一个聪明的计算机黑客可以使用任意不错的数据恢复工具来恢复你删除的数据。Linux 用户利用我们都知晓的 "rm" 命令来从他们的操作系统中删除数据,但是 "rm" 命令在约定俗成的场景下工作。从这个命令删除的数据也可以使用特殊的文件恢复工具恢复。
|
||||
|
||||
让我们看看怎样安全并且完整地从你地 Linux 系统中删除文件或者文件夹。以下提到的工具可以完全地删除数据,因此那些恢复工具很难找到真实数据的痕迹然后恢复它。
|
||||
|
||||
### Secure-Delete ###
|
||||
|
||||
Secure-Delete 是一组为 Linux 操作系统而生的工具集合,他们为永久删除文件提供高级的技术支持。一旦 Secure-Delete 安装在任意的 Linux 系统,它会提供如下的四个命令:
|
||||
|
||||
- srm
|
||||
- smem
|
||||
- sfill
|
||||
- sswap
|
||||
|
||||
在 ubuntu 的终端中运行如下命令安装此工具:
|
||||
|
||||
sudo apt-get install secure-delete
|
||||
|
||||
![secure delete](http://blog.linoxide.com/wp-content/uploads/2015/03/secure-delete.png)
|
||||
|
||||
在 RHEL,Fedora 或者 Centos 中运行如下命令安装此工具:
|
||||
|
||||
sudo yum install secure-delete
|
||||
|
||||
“**srm**” 命令的工作方式和 "rm" 命令类似,但是它不仅仅是删除文件,它首先使用一些随机的数据重写数次文件,然后彻底地删除此文件。这个命令的语法是相当地简单,仅仅指定要删除的文件或者目录,然后它会负责此任务。
|
||||
|
||||
sudo srm /home/aun/Documents/xueo/1.png
|
||||
|
||||
"**sfill**" 检测在指定的分区或者目录被标记为空闲或者可用的空间,然后使用它自身的算法用一些随机数据填充。因此它保证了在此分区没有可以恢复的文件或者文件夹。
|
||||
|
||||
sudo sfill /home
|
||||
|
||||
"**sswap**" 命令用来安全地清除你的交换分区。交换分区用来存放运行程序的数据。首先我们需要运行如下命令来找到你的交换分区。
|
||||
|
||||
cat /proc/swaps
|
||||
|
||||
如下是上述命令的输出示例:
|
||||
|
||||
aun@eagle:~$ cat /proc/swaps
|
||||
Filename Type Size Used Priority
|
||||
/dev/sda5 partition 2084860 71216 -1
|
||||
|
||||
从现在起,你可以看到你的交换分区设置在哪个分区,然后使用如下命令安全地清除。替换 "/dev/sda5" 部分为你的交换分区名字。
|
||||
|
||||
sudo sswap /dev/sda5
|
||||
|
||||
“**smem**” 用来清理在内存中的内容,它保证当系统重启或者关机时随机存取存储器(RAM)中的内容被清理,但是残余的数据痕迹仍然保存在内存。这个命令提供安全的内存清理,简单地在终端中运行 smem 命令。
|
||||
|
||||
smem
|
||||
|
||||
### Shred ###
|
||||
|
||||
"shred" 命令销毁文件或者文件夹的内容,在某种程度上,不可能恢复。它使用随机生成的数据模式来持续重写文件,因此很难恢复任意的被销毁的数据,即使是那些黑客或者窃贼使用高水平的数据恢复工具或者设备。Shred 在 Linux 发行版中时默认安装的,如果你想,你可以运行如下命令来找到它的安装目录:
|
||||
|
||||
aun@eagle:~$ whereis shred
|
||||
|
||||
shred: /usr/bin/shred /usr/share/man/man1/shred.1.gz
|
||||
|
||||
使用 shred 工具运行如下命令来删除文件:
|
||||
|
||||
shred /home/aun/Documents/xueo/1.png
|
||||
|
||||
使用 shred 运行如下命令来删除任意的分区,用你期望的分区来替换分区名字。
|
||||
|
||||
shred /dev/sda5
|
||||
|
||||
Shred 默认情况下使用随机内容重写数据 25 次。如果你想它重写文件更多次数,可以使用 "shred -n" 选项来简单地指定你所期望的次数。
|
||||
|
||||
shred -n 100 filename
|
||||
|
||||
如果你想在重写后截断或者删除文件,使用 "shred -u" 选项:
|
||||
|
||||
shred -u filename
|
||||
|
||||
### dd ###
|
||||
|
||||
这个命令起初是用于磁盘克隆的。它用于一个分区或者一个磁盘复制到另一个分区或者磁盘。但是它还用于安全地清除硬盘或者分区的内容。运行如下命令使用随机数据来重写你的当前数据。你不需要安装 dd 命令,所有的 Linux 分发版都已经包含了此命令。
|
||||
|
||||
sudo dd if=/dev/random of=/dev/sda
|
||||
|
||||
你也可以重写磁盘或者分区中的内容,只需要简单地将所有替换为 “zero”。
|
||||
|
||||
sudo dd if=/dev/zero of=/dev/sda
|
||||
|
||||
### Wipe ###
|
||||
|
||||
Wipe 起初开发的目的是从磁媒体中安全地擦除文件。这个命令行工具使用特殊的模式来重复地写文件。它使用 fsync() 调用和或 O_SYNC 位来强制访问磁盘,并且使用 Gutmann 算法来重复地写。你可以使用此命令删除单个文件,文件夹或者整个磁盘的内容,但是使用 wipe 命令来删除整个磁盘的模式会耗费大量的时间。另外,安装和使用这个工具相当容易。
|
||||
|
||||
在 ubuntu 的终端中运行如下命令来安装 wipe。
|
||||
|
||||
sudo aptitude install wipe
|
||||
|
||||
![Wipe Linux](http://blog.linoxide.com/wp-content/uploads/2015/03/wipe.png)
|
||||
|
||||
使用如下命令在 Redhat Linux,Centos 或者 Fedora 中安装 Wipe:
|
||||
|
||||
sudo yum install wipe
|
||||
|
||||
一旦安装完成,在终端中运行如下命令来获得完整的可用选项列表:
|
||||
|
||||
man wipe
|
||||
|
||||
删除任意文件或者目录:
|
||||
|
||||
wipe filename
|
||||
|
||||
运行如下命令来安全地移除 tmp 分区:
|
||||
|
||||
wipe -r /tmp
|
||||
|
||||
使用如下的命令来删除完整分区的内容(替换分区名字为你所期望的分区)。
|
||||
|
||||
wipe /dev/sda1
|
||||
|
||||
### 小结 ###
|
||||
|
||||
我们期望这篇文章对你有帮助,你的数据隐私是有决定性意义的,在你的系统中安装这些安全的删除工具对你来说非常重要,因此你可以删除你的隐私数据而不用担心它们被轻易地恢复。上面提到的所有工具都是相当轻量的,它们只需要耗费最低的系统资源来运行,并且无论如何也不会影响你的系统性能。享受它们带来的便利吧!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/security/delete-files-permanatly-linux/
|
||||
|
||||
作者:[Aun Raza][a]
|
||||
译者:[dbarobin](https://github.com/dbarobin)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunrz/
|
Loading…
Reference in New Issue
Block a user