Linux command
shred 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Securely delete a file
shred [file]
Shred and remove the file
shred -u [file]
Shred with specific number of passes
shred -n [5] [file]
Shred and zero-fill at end
shred -z [file]
Shred verbosely
shred -v [file]
Shred multiple files
shred -u [file1] [file2] [file3]
Shred a disk partition
sudo shred -v /dev/[sdX]
说明
shred overwrites files to make them harder to recover, then optionally deletes them. It writes random patterns multiple times over the file data, attempting to destroy information at the physical level. By default, shred performs 3 passes of random overwrites. Adding -z performs a final pass with zeros, which makes the shredding less obvious (the file looks simply zeroed rather than deliberately destroyed). Shred can be used on regular files or entire devices (disk partitions). For devices, it overwrites all data on the device. The -u option removes the file after shredding, including attempting to rename it to disguise the original filename before unlinking.
参数
- -u, --remove
- Truncate and remove file after overwriting
- -n _N_, --iterations=_N_
- Overwrite N times (default: 3)
- -z, --zero
- Add final overwrite with zeros to hide shredding
- -v, --verbose
- Show progress
- -f, --force
- Change permissions if necessary to allow writing
- -s _N_, --size=_N_
- Shred only first N bytes (suffixes K, M, G accepted)
- --random-source=_FILE_
- Get random bytes from FILE
- -x, --exact
- Do not round file sizes up to full block
FAQ
What is the shred command used for?
shred overwrites files to make them harder to recover, then optionally deletes them. It writes random patterns multiple times over the file data, attempting to destroy information at the physical level. By default, shred performs 3 passes of random overwrites. Adding -z performs a final pass with zeros, which makes the shredding less obvious (the file looks simply zeroed rather than deliberately destroyed). Shred can be used on regular files or entire devices (disk partitions). For devices, it overwrites all data on the device. The -u option removes the file after shredding, including attempting to rename it to disguise the original filename before unlinking.
How do I run a basic shred example?
Run `shred [file]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -u, --remove do in shred?
Truncate and remove file after overwriting