This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature

CLI Magic: Securely deleting files with shred

By Shashank Sharma on March 06, 2006 (8:00:00 AM)

Share    Print    Comments   

I used to think a simple format of a hard drive was enough to make data recovery impossible, but I was wrong. To ensure that details of your secret love affair, bank account passwords, and daily porn site visits cannot be recovered, use shred.

Deleting a file with the rm command merely adds a file's data blocks back to the system's free list. A file can be restored easily if its "freed" blocks have not been used again. shred repeatedly overwrites a file's space on the hard disk with random data, so even if a data recovery tool finds your file, it will be unreadable. By default, shred does not delete a file, but you can use the -u or --remove switch to delete it.

You can use shred on a file or entire partitions or disks, but you cannot use shred on the partition from which you are running it. In other words, if you have Ubuntu 5.10 installed on /dev/hda1, you cannot boot into it and run the command shred /dev/hda1. Instead, try using Knoppix or another live CD with shred if you wish to work on an entire partition.

By default shred overwrites a file 25 times with random data. You can increase or decrease the number of repetitions using the -n switch. For instance, shred -n 5 -v visit_sites.txt would overwrite the file visit_sites.txt five times and show you the the progress (-v).

If you don't have the right permissions to write a file you can use the -f switch, which changes permissions to allow writing on the file. Another option, the -z switch, writes zeroes on the file after shred overwrites it with random data. This is helpful when you feel that random data in a file might look like encrypted data and arouse suspicion.

When using shred on an entire partition, I suggest you use the -n to reduce the number of passes in order to reduce the time the operation takes.

On completion, shred prints out either zero or a non-zero value to respectively indicate success or failure.

While shred might not work on bad sectors, it is one of the best tools available to securely erase data from your hard disk. It is always more secure to run shred on a complete partition rather than a file, because some filesystems keep backup files and shred makes no attempt to delete these. For the extremely paranoid, however, no command works better than concentrated sulphuric acid.

Shashank Sharma is studying for a degree in computer science. He specializes in writing about free and open source software for new users.

Shashank Sharma specializes in writing about free and open source software for new users and moderates the Linux.com forum boards. He is the coauthor of Beginning Fedora, published by Apress.

Share    Print    Comments   

Comments

on CLI Magic: Securely deleting files with shred

Note: Comments are owned by the poster. We are not responsible for their content.

what is the solution for journalled file systems?

Posted by: Anonymous Coward on March 06, 2006 08:15 PM
I use ReiserFS on all my drives and since shred does not work with journalled filesystems, what can I do to truly delete/overwrite my files?

Many thanks for any ideas!

#

Re:what is the solution for journalled file system

Posted by: Shashank Sharma on March 06, 2006 10:25 PM
The main article was posted to linux.com

<a href="http://www.linux.com/article.pl?sid=06/02/16/2149248" title="linux.com">http://www.linux.com/article.pl?sid=06/02/16/2149<nobr>2<wbr></nobr> 48</a linux.com>

The comments there may be useful for your needs. BTW, I understand that the man shred page says that shred may be ineffective in RESIERFS for single files but it is equally useful if you shred the entire partition.

That is, shred doesn't work on individual files in jouranaling filesystems but the entire partition is no issue.

#

Re:what is the solution for journalled file system

Posted by: Anonymous Coward on March 07, 2006 12:20 AM
It is better to encrypt your<nobr> <wbr></nobr>/swap and<nobr> <wbr></nobr>/home partitions. Then, whether data is present or deleted, doesn't matter, it is just a random jumble of bits.

One distro that makes installing an encrypted file system super easy, is Mandriva. The diskdrake utility (in expert mode) can easily create encrypted file systems.

#

Re:what is the solution for journalled file system

Posted by: Anonymous Coward on March 07, 2006 01:52 AM
One distro that makes installing an encrypted file system super easy, is Mandriva.

Another is Microsoft Windows. In Windows simply right-click the drive/directory/file and choose encrypt. LOL!!!

#

Re:what is the solution for journalled file system

Posted by: Anonymous Coward on March 07, 2006 01:49 PM
Difference between encrypted hdd and shredded hdd is former has 'some' chance of recovery if you can keep it for yourself for some time, but latter, you don't, just as badly as you physically hammered it.

#

ReiserFS

Posted by: Anonymous Coward on March 07, 2006 02:36 PM
Last time I checked, ReiserFS doesn't journal data. ext3 and other journaling filesystems do journal data either by default or as an option. ReiserFS (again, last time I checked) doesn't journal data, it only journals meta-data. So unless your inodes concern you (perhaps filenames?), then there shouldn't be a problem. As others have posted, if you shred the entire partition, then you are a little more secure depending on the number of passes and how badly/how much your opponent has to spend on recovering your data.



So if you understand the meta-data part, using ReiserFS allows you to use shred with more confidence than if you were using ext3 with full data journaling enabled.



You are aware that hard drives are actually as much as 20% or more larger than their rated size, and they use the extra space to swap and remap bad sectors? That means if you have sensitive info on sectors that get remapped, that sensitive info will remain on the swapped out sectors no matter what you do short of physically destructing the platters.



When you finally move to Reiser4, you'll have options/plugins that enable encryption, which will alleviate the concerns on secure deletion just a bit.



shred -fuvz is your friend, shred -fuvz --iterations=30 gives control on number of passes. alias it a few times, high number of iterations for small sized files, lower number of iterations for larger files like<nobr> <wbr></nobr>.iso files, 700 MB divx files and other large files which you'd like to shred in a reasonable amount of time.



Now if someone would print the commands for setting up encrypted swap partitions and encrypted data partitions (not necessarily home, but that's ok to include as well, along with other partitions used for storing data, such as<nobr> <wbr></nobr>/data2/, etc), that would really be appreciated.



I had encrypted swap partitions running knoppix from cd while using the 2.4 kernel, but moving to 2.6 kernel caused me to fail in setting up encrypted swap or encrypted data partitions, especially in Debian.



Currently running 2.6.11 kernel, don't know what dynamic vs static dev is (think I have dynamic), another question that is preventing me from moving to a newer kernel as I believe there is some conflict based on kernel number and static/dynamic dev, or some other related problem.

#

Does not always work on modern file systems

Posted by: Anonymous Coward on March 06, 2006 07:28 PM
Because shred overwrites the a file a couple of times, it works on the principle that the filesystem will write on the same location on the disk every time. This is not the case for some modern filesystems.

Shredding a partition will still for fine. But if you don't know how your filesystem handels rewrites then don't rely on shred to securely delete your files.

See man and/or info pages for more infomation:
$ man info
$ info coreutils shred

#

Re:Does not always work on modern file systems

Posted by: Anonymous Coward on March 07, 2006 02:28 AM
Namely, it doesn't necessarily work on journaled file systems, such as ext3 which is a base for almost every Linux instalation these days.

#

Re:Does not always work on modern file systems

Posted by: Administrator on March 07, 2006 03:44 AM
It does work on JFS, only if you shred the entire partition. If you try to shred only _one file_ you may not be successful.

This is what I understand from the man page.

#

Yes

Posted by: Anonymous Coward on March 06, 2006 09:18 PM
Yes, shred is a useful little tool.<nobr> <wbr></nobr>;)
It is simple to use, and everybody should know about it, but maybe some dont, so its good you mention it.

Other secure data tools is;
* TrueCrypt ( <a href="http://www.truecrypt.org/" title="truecrypt.org">http://www.truecrypt.org/</a truecrypt.org> )
* GnuPG ( <a href="http://www.gnupg.org/" title="gnupg.org">http://www.gnupg.org/</a gnupg.org> )

There are also encrypted and steganographic filesystems such as StegFS, etc.

#

Re:Yes

Posted by: Anonymous Coward on March 07, 2006 10:45 AM
It is simple to use, and everybody should know about it, but maybe some dont, so its good you mention it.

Oh we know about it. It's just that if you are using a journaled filesystem the program is practically useless for you.

#

Re:How do you "shred" files on a modern filesystem

Posted by: Anonymous Coward on March 07, 2006 07:08 AM
Dunno, encryption? Really, securely munching sensitive files would require that the munching tool knows something about the filesystem's format, which means you'll be wanting a filesystem-specific program. Maybe one day we'll see programs for doing so on particular filesystems included in the tools distributed with those filesystems (e.g. reiserfstools, jfstools etc)? It'd be the most logical way, I suppose, of developing and distributing such utilities.

#

Re:How do you "shred" files on a modern filesystem

Posted by: Anonymous Coward on March 08, 2006 12:41 AM
You can "shred" a file on an ext3 filesystem if you first remount the filesystem as ext2 (yes, this can actually be done). The easiest way to do this is to:

umount<nobr> <wbr></nobr>/partition
mount -t ext2<nobr> <wbr></nobr>/device<nobr> <wbr></nobr>/partition

This obviously will not work for other journaled filesystems UNLESS you find a mount option to turn OFF journaling. Even then, it may or may not work, depending on the filesystem.

#

Re:How do you "shred" files on a modern filesystem

Posted by: Anonymous Coward on March 08, 2006 01:35 AM
Won't there still be chunks of the file in the journal, or the blocks where the journal used to be? It seems you would have to mount as Ext2, shred the file, and then shred the free space in the volume.

#

lower back pain

Posted by: Anonymous Coward on May 30, 2006 01:20 AM
[URL=http://nervepainrelief.jeeran.com/painrelief<nobr>.<wbr></nobr> htm] Nerve pain relief [/URL]

  [URL=http://www.back.painreliefnetwork.net/lowbac<nobr>k<wbr></nobr> pain.htm] Low back pain [/URL]

  [URL=http://blog.gala.net/uploads/painreliefback/<nobr>b<wbr></nobr> ackpainrelief.htm] Back pain relief [/URL]

  [URL=http://www.weblog.ro/usercontent/13155/profi<nobr>l<wbr></nobr> es/kneepainrelief.htm] Knee pain relief [/URL]

  [URL=http://www.info.painreliefnetwork.net/Pain-R<nobr>e<wbr></nobr> lief.html] Pain relief [/URL]

  [URL=http://www.sitefights.com/community/scifi/pa<nobr>i<wbr></nobr> nrelief/painreliefpreved.htm] Pain relief [/URL]

  [URL=http://www.info.painreliefnetwork.net/Medica<nobr>t<wbr></nobr> ion-Pain-Relief.html] Medication pain relief [/URL]

  [URL=http://www.info.painreliefnetwork.net/Natura<nobr>l<wbr></nobr> -Pain-Relief.html] Natural pain relief [/URL]


  [URL=http://painrelief.fanspace.com/index.htm] Pain relief [/URL]

  [URL=http://lowerbackpain.0pi.com/backpain.htm] Back Pain [/URL]

  [URL=http://painreliefproduct.guildspace.com] Pain relief [/URL]
[URL=http://painreliefmedic.friendpages.com] Pain relief [/URL]

#

Not random

Posted by: Anonymous Coward on March 08, 2006 02:41 AM
Unless someone has gone and changed it, shred does not "overwrites a file 25 times with random data". Some of the passes are random, but most of them are designed to effectively degauss the disk. This is done by writing bit patterns, which when translated using 1,7 or 2,7 RLL (or a few other encoding schemes) write to the disk with long runs of one, then the other polarity. Subsequent passes shorten the length of the runs. The reason for this is that low frequencies (long runs) penetrate deeper into the disk surface and can't actually be completely erased by higher frequencies (short runs). Actually writing random data will still leak information.

#

Re:How do you "shred" files on a modern filesystem

Posted by: Anonymous Coward on March 09, 2006 09:37 PM
thc's secure-delete utilities: srm, sfill, smem, sswap @ <a href="http://www.thc.org/" title="thc.org">http://www.thc.org/</a thc.org>

works on reiser and ext3

#

How do you "shred" files on a modern filesystem?

Posted by: Administrator on March 07, 2006 05:50 AM
It says in the --help file on shred that it doesn't work on modern filesystems like any of the journaling filesystems.
Ok...that's fine, it still works on partitions. But what do we use on a journaling FS?

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya