How to permanently delete data with Shred

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.

shred_1

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.


5 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Bill said

    Okay, the only thing that doesn't fit me is that I think that on current hard drives with a simple overwrite it is already impossible to recover any data, it is not necessary to do it 25 times. Perhaps it is designed to be used for any type of device, I do not know if tape does need to be overwritten several times to prevent recovery.

  2.   nobody said

    I wonder if this data overwriting is also necessary on SSD hard drives

    1.    Bill said

      SSDs are a separate thing due to their writing system, which always avoids overwriting the same place. So I have searched and explained the matter a bit here:
      http://www.tuwindowsmundo.com/elimina-de-manera-segura-los-archivos-de-tus-unidades-ssd-y-hdd/
      They comment that specific software from each manufacturer is used, they also comment to Parted Magic that it is a linux distribution on whose page they say they use free software such as gparted, etc.
      En la búsqueda veo un artículo anterior de Desdelinux: https://blog.desdelinux.net/como-limpiar-tus-discos-y-borrar-archivos-en-forma-segura/ where it was already commented that it was not 100% effective in an SSD. A comment from "desikoder" gives a good replacement for shred: head -c $ (wc -c FILE) / dev / urandom> FILE
      A study looks bad about deleting an SSD: cseweb.ucsd.edu/~m3wei/assets/pdf/FMS-2010-Secure-Erase.pdf
      So if one day you drop an SSD that had important information on it, be sure to hammer and drill it.
      The explanation on how to mount SSD disks in Linux is interesting, but more in the sense of avoiding fragmentation than actually deleting content: http://www.atareao.es/ubuntu/linux-y-discos-duros-ssd/
      So for now I wouldn't be able to reliably erase something on an SSD.

    2.    Bill said

      SSDs are a separate thing due to their writing system, which always avoids overwriting the same place. So I have searched and explained the matter a bit here:
      http://www.tuwindowsmundo.com/elimina-de-manera-segura-los-archivos-de-tus-unidades-ssd-y-hdd/
      They comment that specific software from each manufacturer is used, they also comment to Parted Magic that it is a linux distribution on whose page they say they use free software such as gparted, etc.
      En la búsqueda veo un artículo anterior de Desdelinux: blog.desdelinux.net/como-limpiar-tus-discos-y-borrar-archivos-en-forma-segura/ donde ya se comentaba que no era 100% efectivo en un SSD. Un comentario de «desikoder» da un buen sustituto de shred: head -c $(wc -c ARCHIVO) /dev/urandom > ARCHIVO
      A study looks bad about deleting an SSD: cseweb.ucsd.edu/~m3wei/assets/pdf/FMS-2010-Secure-Erase.pdf
      So if one day you drop an SSD that had important information on it, be sure to hammer and drill it.
      The explanation on how to mount SSD disks in Linux is interesting, but more in the sense of avoiding fragmentation than actually deleting content: http://www.atareao.es/ubuntu/linux-y-discos-duros-ssd/
      So for now I wouldn't be able to reliably erase something on an SSD.

  3.   nana said

    It would help me but how do I delete files from a GNU disk ???