Delete Files


rm

The rm command (short for remove) deletes files. It really, really removes them. They're gone. There's no trash can or recycle bin on the Linux command line. You're walking a tightrope, baby, and if you fall you go splat!

Okay, that's a little extreme. It's true that the shell lacks an undelete command, but you're not completely hosed if you delete a file. If you stop working on your machine the second you realize your mistake, if the operating system hasn't overwritten the erased file's sectors, and if you can successfully use some rather complicated file recovery software, yes, it's possible to recover files. But it's no fun, and you'll be cursing the whole time. Better to just be careful in the first place.

Tip

Many folks have tried to provide some sort of safety net for rm, ranging from remapping or replacing the rm command to a temporary trash can (www.comwt.com/open_source/projects/trashcan/); to adding a trash can onto the shell (http://pages.stern.nyu.edu/~marriaga/software/libtrash/); to creating a new command, trash, to replace rm (www.ms.unimelb.edu.au/~jrlooker/shell.html#trash).

If, on the other hand, you want to make positively sure that no one can possibly recover your deleted files, even men in black working for shadowy U.S. government agencies, use the shred command instead of rm. The shred command overwrites the file 25 times so it is impossible to re-create it. Before using shred, however, read its man page, as its success rate is highly dependent on the type of filesystem you're using.


Using rm is easy. Some would say almost too easy.

$ pwd /home/scott/libby/by_pool/lieberman_pool $ ls pool_01.jpg      pool_03.jpg pool_01.jpg_bak  pool_03.jpg_bak $ rm pool_01.jpg_bak $ ls pool_01.jpg pool_03.jpg pool_03.jpg_bak 




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net