3

Linux 安全(永久)删除文件和文件夹

 11 months ago
source link: https://xujinzh.github.io/2023/06/01/linux-permanently-delete-file-dir/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Linux 安全(永久)删除文件和文件夹

发表于2023-06-01|更新于2023-06-01|technologylinux
字数总计:389|阅读时长:1分钟|阅读量:3

Linux 系统上的文件或文件夹的安全(永久)删除常用的方法有 shred, wipesrm,下面对其进行介绍。

shred 重写覆盖删除文件

sudo apt update
sudo apt install shred
# 删除文件 filepath.txt
shred -uvz -n 5 filepath.txt

其中,各参数含义:

  • u 覆盖后截断并删除文件
  • v 显示进度
  • z 最后一次用0覆盖,以隐藏覆盖操作
  • n 指定覆盖文件内容的次数,默认是3

更多参数及解释请使用命令 man shred 查看

该方法只能覆盖重写删除文件,无法处理文件夹。

wipe 永久删除磁存储器的文件和文件夹

sudo apt update
sudo apt install wipe
wipe -rfi dirpath

其中,各参数含义:

  • r 递归子目录
  • f 强制删除,不用确认
  • i 显示进度

更多参数及解释请使用命令 man wipe 查看

该方法只能删除磁存储器,对于固态硬盘需要使用其他方法,如下面的方法。

srm 安全删除文件和文件夹

sudo apt update
sudo apt install secure-delete
# 删除文件夹
srm -rvz dirpath
# 删除单个文件
srm -rvz filepath.txt

其中,各参数含义:

  • r 递归子目录
  • v 显示进度
  • z 最后一次使用0覆盖文件内容,而不是随机数

更多参数及解释请使用命令 man srm 查看


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK