Skip to content


How to safely erase (wipe out) files or folders on Linux

I suppose it’s good practice to wipe out sensitive data from a server before giving it back to your host. On Windows, when I want to safely delete files I use Eraser (NB: versions 5.8.x and 6 suck pretty back – for instance they just fail to install for me, seemingly because of a bad packed runtime – You can get version 5.7 from Sourceforge, although its shell integration won’t work in Windows 7). On Linux, until now I had pretty much no idea. But as often, this kind of pretty basic and useful software can be found in usual packages with simple names. And here we are talking about package “wipe”, of course 😉

To install it, pretty straightforward (NB: I’m using Ubuntu, should be the same on Debian; on Fedora should be the same but with yum):
apt-get install wipe

And then to run it, for basic use it will take ALMOST (see below the warning about wildcards) the same kind of options as “rm”:
myLaptop:/home/david$ wipe -r thisFolder
Okay to WIPE 1 directory ? (Yes/No) y
Please answer "Yes" or "No".
Okay to WIPE 1 directory ? (Yes/No) Yes
Wiping ubuntu-11.10-dvd-amd64.iso, pass 9 (12) [ 213 / 5994]

The default setting is 34 overwrite passes, which is huge and slow, but I guess helpful if you are paranoid. If you want fewer passes, use -Q [number of passes]. The manual might be an interesting read, too.

A very important warning about using wildcards: DO NOT use wipe -r .*. As reported there, this pattern matches .. so wipe will then browse around and erase the whole disk if you’re running it as root (and even if you’re not, it will likely get to places where you didn’t want it to go). This is not a bug, it’s actually a feature. rm not matching .. when you call it on .* is a safeguard, but when you’re using wipe chances are that it’s more of a problem to miss deletions than to do too many of them, thus this aggressive behavior. I didn’t try it but most likely this is true of wipe -r * too.

If you want to erase all the dot files in a folder, you can either use wipe .??* or move on level up and do wipe -r theFolder, like I did in my example.

Edit: actually, I did gave a shot at wipe -q -r .* on a virtual box, it didn’t wipe everything out, as can be seen from the output:
root@xxxxx:~# wipe -q -r .*
Okay to WIPE 9 regular files and 7 directories ? (Yes/No) Yes
Will not remove .
Will not remove ..
Operation finished.

Finally, I thought that could be useful on Windows so I checked out: unfortunately wipe is not available in Cygwin as of today.

Posted in Linux, privacy.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA