tft每日頭條

 > 科技

 > linux中如何建立和删除文件

linux中如何建立和删除文件

科技 更新时间:2024-10-20 08:16:54
概述

在大多數情況下,我們在linux中删除文件和目錄是通過rm命令,這些方法并不能永久、安全地從硬盤(或任何存儲介質)中删除文件。

假設文件包含機密或機密内容,例如系統的用戶名和密碼,攻擊者可以輕松恢複文件的已删除副本并訪問這些文件 。

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

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

1、安裝軟件包

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

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

選項說明:

  • -z- 添加一個帶有零的最終覆蓋以隐藏切碎
  • -v– 可以顯示操作進度
  • -u- 覆蓋後截斷和删除文件
  • -n– 指定覆蓋文件内容的次數(默認為 3)

3、示例

shred覆蓋文件以隐藏其内容,也可以選擇删除它。

$ shred -zvu -n 5 passwords.list

linux中如何建立和删除文件(中永久安全地删除)1

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

Linux wipe命令可以安全地從磁存儲器中擦除文件,從而無法恢複。

1、安裝軟件包

首先,您需要安裝擦除工具,運行下面的相應命令:

$ sudo yum install wipe [On RedHat based systems]

2、命令及參數選項

$wipe --help

選項:

  • -r- 告訴擦除遞歸到子目錄
  • -f- 啟用強制删除和禁用确認
  • -i- 顯示删除過程的進度

3、示例

以下命令将銷毀目錄private下的所有内容。

$ wipe -rfi private/*

[

linux中如何建立和删除文件(中永久安全地删除)2

三、Linux 安全删除工具包

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

1、安裝軟件包

首先,您需要使用以下相關命令安裝它:

$ 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

選項:

  • -f - 強制删除
  • -r - 遞歸删除,删除目錄及目錄中的内容
  • -v – 啟用詳細模式
  • -z– 用零而不是随機數據擦除最後一次寫入

3、示例

您可以使用srm工具在 Linux 系統上安全地删除文件或目錄,如下所示。

$ srm -vz private/*

[

linux中如何建立和删除文件(中永久安全地删除)3

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved