Shredding a file in Linux with shred

When deleting a file by simply pressing the delete button the file can be easily recovered, you don’t always want that. That’s where shred comes in, What shred does is to wipe the file and make it unrecoverable. This can be very useful if you want to delete a file with sensitive data.

Usage

shred [options] [file]

Basic options :
        -f    force permissions
        -u   remove after
        -v   verbose
        -z   write zeros at the end
        -n [number]   times of shredding
If you are not running the command as root, you need to add sudo.
Shred is part of the coreutils package so you will have to download that if it’s not in your system.

For more options see the man page :

man shred

Example

      For this example i have created a text file named secret.txt.

To shred the file enter the following command:

sudo shred -f -u -v -z -n 34 secret.txt

And execute the command. The time required to shred the file depends on size of the file. This small text file is wiped almost instantly.

And you can see in bellow that the file has been safely deleted.

Leave a Reply