Javatpoint Logo
Javatpoint Logo

shred

The shred command allows us to delete our files securely making it very much difficult to recover that file by anyone.

Erasing a file with rm command only erases the file system entry and keeps the content of the file intact. It is quite easy to recover removed files content using some softwares.

To prevent from data recovering, shred overwrite the data multiple times by doing maximum destruction of the data.

Shred can be used on files as well as devices such as hard disk partition. By default, shred overwrites file three times with different patterns, but this number can be changed.

On normal deletion of file, that portion is simply marked to be used for another file, but data of that file is still present. Those data, can be retrieved through some advanced softwares.

This command is very much helpful when you want to permanently remove files containing sensitive data. To remove these type of files rm command is not sufficient.


Shred command without argument

Syntax:

Example:

shred abc.txt

Linux Shred1

Look at the above snapshot, file abc.txt is created. It need to be securely deleted as it contains confidential data.

Now, after passing shred command to the above file, it displays following output.

Linux Shred2

Look at the above snapshot, data of the file is shreded but file still remains there.


To delete file

Use of shred command without any argument only overwrites the file content, but file still remains in the file system.

To delete the file from the file system, use option u.

Syntax:

Example:

shred -u abc.txt

Linux Shred3

Look at the above snapshot, file is deleted from the file system.


Verbose information about shred process

If you want to see what shred is doing with your file use option v.

Here, we are using u option to remove the file as well.

Syntax:

Example:

shred -u -v abc.txt

Linux Shred4

Look at the above snapshot, by default three times the file has been overwritten and seven times it is renamed.


Changing overwrite number

You can also change the overwrite number from default (which is 3) to whatever you want using option n.

Syntax:

Example:

shred -u -v -n 9 abc.txt

Linux Shred5

Look at the above snapshot, nine times the file has been overwritten.


Using shred on a drive

The shred command is also used to overwrite the data of a drive. Drive contains a huge amount of data, hence, a lot of time will be required to shred this data.

Syntax:

Example:

shred /dev/sda1

Next TopicLinux mount





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA