Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is rm final? 1

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hello,
A quick question.. If I do a rm on a file, is that file then gone forever or si it somewhere else? Suppose that every day a file of 10MB gets created, then deleted (with rm). Will I have a full 'recycle bin' at some stage or is the file really gone?
 
It's pretty much gone forever (though there have been recent threads in the unix forums which suggested ways in which to recover recently deleted files which sounded interesting). Once the parts of the disk the file was written to have been overwritten, there's no going back I'm afraid. HTH.
 
Depends on what you mean by really gone and also depends upon your file system, your os, and rm itself.

First: traditional Unix:

When you rm a file all that happens is that the directory entry is set to point at 0 instead of the inode it did point at, and the link count for the inode is decremented by one. If the link count has reached 0, and no process has the file open, then the inode itself is marked us unused, and the disk blocks that the file used are returned to the free list. If a process has the file open then the release of the inode and the reclaim of disk blocks waits until the process is done.

So, at this point, your data is still there until some other process needs disk blocks and these happen to get reused. If nothing asks for new blocks, or these blocks get put at the end of the free list, you might be able to recover the data by scrounging through the free list.

Secure Unix systems may zero disk blocks before releasing them to the free list; you wouldn't have any way to get your data if that was in effect.

Now: Some file systems have various schemes to keep "versions" of your data or to provide an undelete feature. In that case, older copies of your data maty still be there. However, even if your file system supports something like that, it may not be turned on by default: see for example.

Linux ext2 file systems document an undelete in chattr but it isn't actually implemented at all :)

Spome systems mess with rm either by an alias or a binary to store the "deleted" file somewhere safe for a while.



Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
There are "ways" to recover stuff that has been deleted,see the util
You could of course (if you have enough space) mv the rm command and replace it with your own script that move the file to another directory, called trash like on Tru64.

You can also recovery using the inode list.

Mike --
| Mike Nixon
| Unix Admin
| ----------------------------
 
Thank you very much everybody. I was actually not looking to recover anything but a bit concerned that my box could crash if it filled up withold 'deleted' files. As this doesn't seem to be the case I can relax...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top