Surely more than once it has happened to you that you accidentally delete some data, or you thought it was no longer necessary and it turns out that later you need to recover that information and that thanks to some program or some code you can recover; But what if you need to permanently delete data? Just as there are recovery tools we can also find destruction tools, such as shred
This tool comes inside the package coreutils which is pre-installed within any Linux distribution, this coreutils package includes a series of elementary tools for the command line, among which is shred, it is nothing more than a utility that stands out for being very simple to use and above all effective for destroy everything we need (or what we no longer need) just as its name says.
The operation of shred is that it basically overwrites the file or data that we indicate several times (25 by default) this is done using various text schemes, to convert everything that the original file contains, into another completely different content with nonsense information.
For users who are not familiar, they can review everything that this tool allows us with a glance at the man shred.
After this let's go to the practical part; Let's start with an example of its use, first to see what it is about we will take a hard disk or some partition: if we had the partition controlled by size, using the command lsblk we immediately locate the partition we need, with the command umount would be disassembled and then with shred we will give you the review timely:
shred -vzn 0 / dev / sda1
With the previous line we would be eliminating all the data that is in the partition “sda1” and with the other parameters such as “v” that shows us the progress of the operation, “z” that helps us to cover up the destruction by overwriting with zeros at the end and "n" followed by a zero, which means that the process will be carried out only once without repeating itself; the more the process is repeated, the more efficient the deletion, what if you have to keep in mind when using Shred is that this it's a slow process, especially if we are going to use it on discs of considerable sizes; That example that illustrates them would be recommended for use by a user who is not an expert or a common user.
If we are going to delete a file it would be simpler and much faster:
shred -u / path / file
Option "u" is in charge of erasing the data. However, if we come across a very large file, we can perfectly use the same step, we only add the delete parameter and we tell it to repeat the process three times:
shred -ubzn 2 / path / file
The part where we must be careful is in where do we use shred, because it may not work well with some storage configurations or with all file systems.