views:

78

answers:

3

Many programs have created a huge amount of swap files. They annoy me, because some of them contain sensitive information. How should I deal with them? Is this command a good idea:

find . -iname "*swp*" -exec rm '{}' \;

How should good programs handle their swap files?

+1  A: 

depends where it's run from, but it should be fine, though I would ammend the match to be "*.swp" or "*swp" for a more perfect match

Luke Schafer
+1  A: 

if they run as your user id then the files created probably aren't readable by anyone else. If they are then you have deeper security issues.

SpliFF
+1  A: 

If the files "annoy" you because they contain sensitive information, then you should know that simply removing the files with the rm command does not actually erase the data fro your hard drive.

I'm not really sure where your swap files are or what application is creating them. Typically swap files are created by the operating system in a specially-designated directory. For example, on my Mac:

$ ls /private/var/vm/
-rw------T  1 root  wheel  4294967296 Mar 15 19:41 sleepimage
-rw-------  1 root  wheel    67108864 Mar 15 21:10 swapfile0
$ 

If you want to erase the information in the swap files, you really need to overwrite them. You can do that with "dd" but you are better off doing it with srm. Unfortunately, srm defaults to overwriting each file 7 times, which is 6 times more than is necessary. (Use it with the -s option to get a single overwrite).

So if you want to use your find, use:

find . -iname "*swp*" -exec srm -s {} \;

Make sense?

vy32
I believe these are not the type of swap file the OP is talking about, but you're right about rm leaving the data on the disk until it is later overwritten.
Roger Pate