命令行大全

shred

秃噜豆儿 发表于 2020-07-23 15:15浏览次数:

在Linux操作系统上,一种分解操作,它覆盖一个文件以隐藏其内容,并有选择地删除它。 shred程序是由GNU项目创建的。在非Linux操作系统上,它的命令名为gshred。

查看英文版

目录:

1 shred 运行系统环境

2 shred 描述

3 shred 语法

4 shred 选项

5 shred 示例

shred 运行系统环境

Unix&Linux

shred 描述

shred是一个程序,它将覆盖您的文件,使它们很难被第三方恢复。
通常,当您删除一个文件时,磁盘的那部分被标记为准备好写入另一个文件,但数据仍然存在。如果第三方获得对磁盘的物理访问权,他们可以使用高级技术访问您认为已删除的数据。
这个比喻就是碎纸机。如果你把一张纸揉成一团扔进垃圾桶里,第三方就会出现,在你的垃圾堆里翻找,找到你丢弃的文件。如果你真的想销毁文件,最好用碎纸机。或者把它烧掉,但在一个典型的办公室里,这并不总是实用的。
shred以数字方式完成这种类型的销毁的方法是覆盖(一遍又一遍,重复,按指定的次数)要销毁的数据,用其他(通常是随机的)数据替换它。这样做会破坏磁盘上的数据,使其极不可能被恢复。
shred is a program that will overwrite your files in a way that makes them very difficult to recover by a third party.
Normally, when you delete a file, that portion of the disk is marked as being ready for another file to be written to it, but the data is still there. If a third party were to gain physical access to your disk, they could, using advanced techniques, access the data that you thought you had deleted.
The analogy is that of a paper shredder. If you crumple up a piece of paper and throw it in the trash can, a third party could come along, root through your trash, and find your discarded documents. If you really want to destroy the document, it's best to use a paper shredder. Or burn it, I suppose, but that's not always practical in a typical office.
The way that shred accomplishes this type of destruction digitally is to overwrite (over and over, repeatedly, as many times as you specify) the data you want to destroy, replacing it with other (usually random) data. Doing this magnetically destroys the data on the disk and makes it highly improbable that it can ever be recovered.

查看英文版

查看中文版

shred 语法

shred [OPTIONS]FILE[...]
shred [OPTIONS]FILE[...]

查看英文版

查看中文版

shred 选项

-f, --force 如有必要,更改权限以允许写入。
-n, --iterations=N 覆盖N次而不是默认值(3)。
-s, --size=N 切碎这么多字节(接受后缀,如K,M,G)。
-u, --remove 覆盖后截断并删除文件。
-v, --verbose 显示有关切碎进度的详细信息。
-x, --exact 不要将文件大小四舍五入到下一个完整的块;这是非常规文件(例如设备名称)的默认设置。
-z, --zero 添加最终的零覆盖以隐藏切碎。
- 切碎标准输出。
--help 显示此帮助并退出。
--version 输出版本信息并退出。
-f--force Change permissions to allow writing if necessary.
-n--iterations=N Overwrite N times instead of the default (3).
-s--size=N Shred this many bytes (suffixes like K, M, G accepted).
-u--remove Truncate and remove file after overwriting.
-v--verbose Show verbose information about shredding progress.
-x--exact Do not round file sizes up to the next full block; this is the default for non-regular files such as device names.
-z--zero Add a final overwrite with zeros to hide shredding.
- Shred standard output.
--help Display this help and exit.
--version Output version information and exit.

销毁文件数据后,如果指定了--remove(-u),则shred还将删除文件。默认情况下不删除这些文件,因为在像/dev/hda这样的整个设备文件上操作是很常见的,而且这些文件通常不应该被删除。当操作常规文件时,大多数人使用--remove选项。 注意:请注意,shred依赖于一个重要的假设:文件系统“就地”覆盖数据。这个假设是传统的方法,但许多现代文件系统并不是这样做的。以下是文件系统的示例,其中“碎片”在所有文件系统模式下都无效或不能保证有效: 日志结构或日志文件系统,如AIX和Solaris(以及JFS、ReiserFS、XFS、Ext3等)提供的文件系统 写入冗余数据并在某些写入失败时仍继续执行的文件系统,如基于RAID的文件系统 生成快照的文件系统,如Network Appliance的NFS服务器 在临时位置缓存的文件系统,如nfsversion3客户端 压缩文件系统 对于ext3文件系统,上面的免责声明只适用于data=journal模式,除了文件元数据外,还记录文件数据。在data=ordered(默认)和data=writeback模式下,shred与平常一样工作。Ext3日志记录模式可以通过将data=something选项添加到/etc/fstab文件中特定文件系统的装载选项中来更改,如装载手册中所述。 此外,文件系统备份和远程镜像可能包含无法删除的文件副本,这将允许以后恢复碎片文件。

After destroying the FILE data, shred will also delete the FILE(s) if --remove (-u) is specified. The default is not to remove the files because it is common to operate on entire device files like /dev/hda, and those files usually should not be removed. When operating on regular files, most people use the --remove option. CAUTION: Take note that shred relies on an important assumption: that the file system overwrites data "in-place." This assumption is the traditional way to do things, but many modern file systems do not do things exactly this way. The following are examples of file systems on which shred is not effective, or is not guaranteed to be effective in all file system modes: log-structured or journaled file systems, such as those supplied with AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.) file systems that write redundant data and carry on even if some writes fail, such as RAID-based file systems file systems that make snapshots, such as Network Appliance's NFS server file systems that cache in temporary locations, such as NFS version 3 clients compressed file systems In the case of ext3 file systems, the above disclaimer applies (and shred is thus of limited effectiveness) only in data=journal mode, which journals file data in addition to file metadata. In both the data=ordered (default) and data=writeback modes, shred works as usual. Ext3 journaling modes can be changed by adding the data=something option to the mount options for a particular file system in the /etc/fstab file, as documented in the mount manual. Also, file system backups and remote mirrors may contain copies of the file that cannot be removed, and that will allow a shredded file to be recovered later.

查看英文版

查看中文版

shred 示例

shred file1.txt file2.jpg file3.doc

使用默认的分解方法覆盖file1.txt、file2.jpg和file3.doc的数据。

shred -u file1.txt file2.jpg file3.doc

同上,但也要删除这三个文件,释放磁盘上的空间供以后使用。

shred /dev/hda6

覆盖分区/dev/hda6上的所有数据。

shred file1.txt file2.jpg file3.doc

Overwrite the data of file1.txt, file2.jpg, and file3.doc using the default shredding methods.

shred -u file1.txt file2.jpg file3.doc

Same as above, but also delete those three files, freeing up that space on the disk for later use.

shred /dev/hda6

Overwrite all data on the partition /dev/hda6.

查看英文版

查看中文版