Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Delete File which can never be recovered
- ##################################################################
- Join our telegram channel for more : https://t.me/LinuxClassesEFXTv
- ##################################################################
- #-----------------------------------------------------------
- The `shred` command in Linux is used to securely delete files by overwriting them with random data, making data recovery very difficult. However, it does not remove directory structures or delete folders directly. It's meant specifically for files.
- ๐ง Basic Syntax:
- shred [OPTIONS] FILE...
- โ Common Use Cases:
- 1. ๐๏ธ Securely Delete a Single File
- # -u = truncate and remove file after overwriting
- shred -u filename
- 2. ๐งน Overwrite a File (but don't delete)
- # File remains, but content is overwritten multiple times
- shred filename
- 3. ๐ Increase Overwrite Iterations
- # -n 10 = overwrite file 10 times (default is 3)
- # -u = delete file after overwriting
- shred -n 10 -u filename
- 4. ๐ชต Verbose Output
- # Shows progress for each file
- shred -v -u filename
- โ `shred` Cannot Directly:
- - Delete folders
- - Shred recursively
- - Wipe filesystems
- ๐ Workarounds for Your Scenarios:
- โ Delete a Folder With Files Securely
- # This securely deletes all files, then removes folder structure
- find /path/to/folder -type f -exec shred -u {} \;
- rm -rf /path/to/folder
- โ Delete All Subfolders in PWD
- # Recursively shred files in subdirectories and remove them
- for dir in */; do
- find "$dir" -type f -exec shred -u {} \;
- rm -rf "$dir"
- done
- ๐ฃ Destroy the Entire Disk (Not Just Files)
- # Replace /dev/sdX with the disk device (e.g., /dev/sda)
- sudo shred -v -n 3 /dev/sdX
- โ ๏ธ Notes and Limitations:
- - Not effective on journaling filesystems like ext3/ext4 with journaling enabled
- - Not reliable on SSDs/Flash drives (due to wear leveling)
- - Use `blkdiscard`, `cryptsetup luksFormat`, or manufacturer tools for SSDs
- #-----------------------------------------------------------
Advertisement
Advertisement