October 15, 2011 Leave a comment
One of the various Linux tools for secure deletion of files is the
srm command. In Gentoo Linux the
srm command and other security-related commands are available by installing the package secure-delete. Now,
srm is easy enough to use from the command line:
$ srm mysecrets.doc
You can do the same thing from the KDE GUI very easily by adding the
srm command to the KDE Service Menu. To do this, first install KDE Service Menu Editor. Then launch it and do the following:
On the Actions tab:
1. Enter “Securely Delete” (without the quotes) in the Label box.
srm -r %u in the Exec box. As you will see if you use the
man srm command, the “-r” option means “recursive mode, deletes all subdirectories”. I’ve added this option so that I can securely delete directories and all their contents including sub-directories, as well as individual files.
3. Click on the blank Icon and choose a suitable icon. I selected System Icons > Actions, entered “delete” (without the quotes) in the Search box and selected the big red X (edit-delete) icon.
On the Conditions tab:
4. Against ‘Display the menu for:’, click on All Files.
5. Click OK then Close, and you’re done.
Now all you need to do in KDE is right-click on a file or directory and select Actions > Securely Delete.
The above configuration will only allow you to delete files and directories owned by your user name. However, if you also want to be able to delete files owned by other Linux accounts on your machine then you can modify the command in the KDE Service Menu to prompt you for the root user’s password. To do that, in Step 2 above you would use the following command instead:
kdesu srm -r %u
Now when you right-click on a file or directory, a window will pop up and prompt you to enter the root user’s password.
Of course, if you would prefer to use a different tool to securely delete a file or directory then you could substitute the
srm command with e.g.
bcwipe if you have those installed. Use
man wipe and
man bcwipe after installing them, to check which options you might want to use.
Note that some of your data might be in a temporary (deleted) copy of the file somewhere on the disk. If you installed the secure-delete package then you could use the
sfill command to wipe free disk space on any mounted partition, but you would need to be root user to use it. Note also that, if a small file has already acquired a block with your data, no tool can remove that data. Anyway, if you also want to securely wipe any free disk space you can modify the aforementioned command in the KDE Service Menu even further:
kdesu srm -r %u && kdesu sfill directory/mountpoint
I have my /home directory on its own partition, so, in my case the KDE Service Menu entry would be:
kdesu srm -r %u && kdesu sfill /home
This would pop up a window twice prompting you to enter the root user’s password: once for the srm command, and once for the
sfill command. Note that the
sfill command can take a very, very long time to wipe the free space if it is large (I personally don’t bother using it, as I don’t want my hard disk thrashing for hours). The
sfill command works by creating one big file to fill all the free space, then writes to that file using several steps to ensure all the previously-free areas of the disk have had their original contents erased. Once that is completed, the utility then removes the big file, releasing the free disk space.
If you think your swap space contains some of your data, you could use the
sswap command — also available if you install the secure-delete package — for secure deletion of the swap space, but you would need to disable your swap space first. I have 4 GB of RAM and my swap partition is virtually never used, so I don’t bother putting my tinfoil hat on in the case of swap either.