- Join BJ's Wholesale Club for just $20 right now to save on holiday shopping
- This $28 'magic arm' makes taking pictures so much easier (and it's only $20 for Black Friday)
- Two free ways to get a Perplexity Pro subscription for one year
- The 40+ best Black Friday PlayStation 5 deals 2024: Deals available now
- The 25+ best Black Friday Nintendo Switch deals 2024
Shredding files on Linux with the shred command
$ file guitar* guitar.png: data guitar.png-save: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, Exif Standard: [TIFF image data, little-endian, direntries=5, xresolution=74, yresolution=82, resolutionunit=2, software=GIMP 2.10.8, datetime=2019:02:04 18:48:41], progressive, precision 8, 512x512, components 3
The shredded file is described simply as “data” while the copy of the original file describes the file’s content with all the numerous details about its format that you would normally expect to see.
By default, the shred command will overwrite a file three times, but you can change this by using the -n option (e.g., shred -n 25 guitar.png). The process is surprisingly fast, even if you decide to shred it many times.
If you want to shred a file numerous times and get some feedback on what is happening, add the -v option as shown below.
$ shred -vn 10 guitar.png shred: guitar.png: pass 1/10 (random)... shred: guitar.png: pass 2/10 (aaaaaa)... shred: guitar.png: pass 3/10 (ffffff)... shred: guitar.png: pass 4/10 (249249)... shred: guitar.png: pass 5/10 (db6db6)... shred: guitar.png: pass 6/10 (random)... shred: guitar.png: pass 7/10 (000000)... shred: guitar.png: pass 8/10 (492492)... shred: guitar.png: pass 9/10 (555555)... shred: guitar.png: pass 10/10 (random)...
Use the -u option if you want shred to remove the file from your file system. It will deallocate and remove the file after overwriting it. Only the un-shredded copy of the file is still available.
$ shred -u smiley.jpg $ ls -l smiley* -r--r--r--. 1 shs shs 14120 Apr 15 14:05 smiley.jpg-save
If you want, you can even shred only a specified number of bytes in a file. Here’s an example, starting with a little story:
$ cat story Once upon a time, a long time ago, there was a clever witch who decided to use the Linux shred command to get rid of her competitor's spells on a shared computer.
When the story is shredded with the argument below, the requested number of bytes are affected.