Jan 29 2026
The shred command is a powerful Linux utility used to securely delete files by overwriting them multiple times with random data. This ensures that the contents of the file cannot be recovered by data recovery tools or forensic analysis.
Basic Syntax: shred [options] [file...]
| Option | Description |
|---|---|
| -n | Number of times to overwrite the file (default: 5) |
| -z | Add a final overwrite with zeros (useful for hiding the file size) |
| -u | Remove the file after overwriting |
| -v | Verbose mode (shows progress) |
| -e | Specify the erase method (e.g., --random for random data) |
shred -v sensitive_data.txtsensitive_data.txt by overwriting it 5 times.shred -n 10 -v secret_credentials.txtsecret_credentials.txt 10 times with random data.shred -u -v important_report.txtshred -r -v /path/to/directory-r option tells shred to recursively delete all files and subdirectories within the specified directory.shred -z -v confidential_log.txt| Use Case | When to Use shred |
|---|---|
| Delete sensitive files | Always |
| Erase data from a drive | Before selling or disposing of a drive |
| Securely erase logs | After logging sensitive information |
| Comply with data protection laws | GDPR, HIPAA, etc. |
The rm command only deletes the file entry in the file system. The actual data remains on the disk until it's overwritten. So, for sensitive data, always use shred instead.
shred -u file.txt.