概述

在大多数情况下,我们在linux中删掉文件和目录是通过rm命令linux删除文件夹下所有文件,这种方式并不能永久、安全地从硬碟(或任何储存介质)中删掉文件。

假定文件包含绝密或绝密内容,比如系统的用户名和密码linux培训机构,功击者可以轻松恢复文件的已删掉副本并访问那些文件。

在本文中,我们分享一些用于在Linux中永久安全地删掉文件的命令行工具。

一、Shred-覆盖文件以隐藏内容

1、安装软件

yum install coreutils-8.22-24.el7_9.2.x86_64 -y

删除文件linux_linux删除文件夹下所有文件_linux误删除文件夹

2、命令及参数选项

[root@192_168_209_128 ~]# shred --help
Usage: shred [OPTION]... FILE...
Overwrite the specified FILE(s) repeatedly, in order to make it harder
for even very expensive hardware probing to recover the data.
Mandatory arguments to long options are mandatory for short options too.
  -f, --force    change permissions to allow writing if necessary
  -n, --iterations=N  overwrite N times instead of the default (3)
      --random-source=FILE  get random bytes from FILE
  -s, --size=N   shred this many bytes (suffixes like K, M, G accepted)
  -u, --remove[=HOW]  truncate and remove file after overwriting; See below
  -v, --verbose  show progress
  -x, --exact    do not round file sizes up to the next full block;
                   this is the default for non-regular files
  -z, --zero     add a final overwrite with zeros to hide shredding
      --help     display this help and exit
      --version  output version information and exit

选项说明:

3、示例

shred覆盖文件以隐藏其内容,也可以选择删掉它。

$ shred -zvu -n  5 passwords.list

删除文件linux_linux误删除文件夹_linux删除文件夹下所有文件

二、Wipe—在Linux中安全擦除文件

Linuxwipe命令可以安全地从磁储存器中擦除文件,因而未能恢复。

1、安装软件包

首先,您须要安装擦除工具,运行下边的相应命令:

$ sudo yum install wipe       [On RedHat based systems]

linux删除文件夹下所有文件_删除文件linux_linux误删除文件夹

2、命令及参数选项

$wipe --help

选项:

3、示例

以下命令将销毁目录private下的所有内容。

$ wipe -rfi private/*

linux误删除文件夹_linux删除文件夹下所有文件_删除文件linux

三、Linux安全删掉工具包

Secure-delete是一个安全文件删掉工具的集合,其中包含srm(secure_deletion)工具,用于安全删掉文件。

1、安装软件包

首先linux系统下载,您须要使用以下相关命令安装它:

$ sudo yum install secure-delete       [On RedHat based systems]

2、命令及参数选项

$[root@192_168_209_128]# srm --help
Usage: srm [OPTION]... [FILE]...
Overwrite and remove (unlink) the files. By default use the 35-pass Gutmann
method to overwrite files.
  -d, --directory       ignored (for compatability with rm(1))
  -f, --force           ignore nonexistant files, never prompt
  -i, --interactive     prompt before any removal
  -x, --one-file-system do not cross file system boundaries
  -s, --simple          overwrite with single pass using 0x00 (default)
  -P, --openbsd         overwrite with three passes like OpenBSD rm
  -D, --dod             overwrite with 7 US DoD compliant passes
  -E, --doe             overwrite with 3 US DoE compliant passes
  -G, --gutmann         overwrite with 35-pass Gutmann method
  -C, --rcmp            overwrite with Royal Canadian Mounted Police passes
  -r, -R, --recursive   remove the contents of directories
  -v, --verbose         explain what is being done
  -h, --help            display this help and exit
  -V, --version         display version information and exit

选项:

3、示例

您可以使用srm工具在Linux系统上安全地删掉文件或目录linux删除文件夹下所有文件,如下所示。

$ srm -vz private/*

linux误删除文件夹_linux删除文件夹下所有文件_删除文件linux

Tagged:
Author

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。

发表回复