How to delete large files or directories in Linux?

Erase Hard Drive with Eraser

You all already know how delete files and directories in Linux, both from the tools available from the desktop environment to those that are given to us from the shell (such as the command that everyone will know, rm). But in this mini tutorial we will focus on how to erase large data, those that occupy several GB on our hard drive and that it may be interesting to delete them to recover some space on our storage unit.

When we delete data that has a lower content, this is usually not too problematic, since it does not mean a great burden on the system planning of I / O and the storage unit in question, as well as a large consumption of RAM, especially when using certain tools. But if it is very heavy files, such as some high-duration video and in HD in certain formats, or databases, directories with a lot of multimedia content, etc., the problem grows in the temporal aspect, since it takes us a little more to carry out the process when dealing with large spaces.

There are tools like shred and secure-deletion tookit For the safe erasure of data, but not to overload the system too much when erasing this monstrous data we are interested in our command of a lifetime, rm and also in combination with another command called ionice. If you don't have it on your distro, install it ...

It sure reminds you of another old acquaintance, nice, well yes, ionice is the nice of the input and output, allowing you to assign priority to different things, not only to delete data, but also to speed up other tasks such as transfers (ripping), moving data, etc. For example, what mode 3 would do is perform the deletion task when the system is free and we are not performing other priority tasks. For instance:

sudo ionice -c 3 rm /nombre/fichero/o/directorio/a/borrar

Each number acts differently for it I / O scheduler or scheduler. A 0 is nothing, 1 for real time, 2 for low priority, and 3 for IDLE mode. If we do not want to delay the task too much, we can give it a 2 and it will be done in a somewhat faster way than in idle mode, but it does not slow down too much like doing it in real time ...

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: AB Internet Networks 2008 SL
  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.