如何用bash覆盖文件中的数据

发布于 2024-08-28 19:13:39 字数 402 浏览 7 评论 0原文

我正在编写一个 bash 脚本来加密文件夹或文件的数据

#!/bin/bash

file_name=$1
tmp_file=/tmp/tmpfile.tar

# tar compress file
tar -cf $tmp_file $file_name;

# encrypt file
gpg -c $tmp_file

# remove temp file
rm -rf $tmp_file $file_name

# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name

,但数据仍然可以通过使用 photorec 或类似方法恢复...

有没有办法确保绝对删除bash 中的原始文件?

I'm writing a bash script that encrypts the data of a folder or file

#!/bin/bash

file_name=$1
tmp_file=/tmp/tmpfile.tar

# tar compress file
tar -cf $tmp_file $file_name;

# encrypt file
gpg -c $tmp_file

# remove temp file
rm -rf $tmp_file $file_name

# mv encrypted file to orignal place
mv ${tmp_file}.gpg $file_name

but the data will still be recoverable by using photorec or similar methods...

Is there a way to ensure the absolute deletion of the original file in bash?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

请别遗忘我 2024-09-04 19:13:39

您可以尝试 srm擦除

you can try srm or wipe

我是男神闪亮亮 2024-09-04 19:13:39

我认为不可能将文件通过管道传输到 gpg 中,因为您已经尝试过了?

I gather it is impossible to just pipe the file into gpg, as you would already have tried that?

西瓜 2024-09-04 19:13:39

这也应该有效:

rm -Pf file

This should also work:

rm -Pf file
猫九 2024-09-04 19:13:39

您可以创建一个 ramdisk 来创建临时文件吗?或者,如果数据如此敏感,也许您应该使用加密的文件系统?

Can you create a ramdisk to create the temp file in? Alternatively if the data is that sensitive maybe you should be using an encrypted file system?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文