This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes Recovery of file after removing it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Recovery of file after removing it?" Watch "Recovery of file after removing it?" New topic
Author

Recovery of file after removing it?

minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
If I removing a file using rm command, then "rm" command will delete a name-inode map from a directory.

Can I recover this removed file?


Minal Silimkar
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Minal,
Not easily if at all. If you have backups, you can do a restore from there. If not, you can look if there is a tool that can restore files (I don't know if there is one.) Even then, that assumes the file has been overwritten yet.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes, Linux file systems aren't like FAT disks. The best thing to do in this case is IMMEDIATELY shut the machine off, and bring it up in single-user mode with the disk containing the deleted file mounted read-only (this may mean booting off of a CD, or even moving the disk to another machine.) Then you can dump the partition with the deleted file using "dd"; now you've got all the remaining data in that dump, and you can reboot the machine normally.

Now, if the deleted file was a text file, you can just search the dump file for some text you know was in the deleted file. If it was something binary, then there are a few programs that can help you examine the dump, depending on what type of file system it was. For an ext2fs partition, there's the "recover" command (Google "Linux recover deleted files").


[Jess in Action][AskingGoodQuestions]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

most of the linux gui shells, gnome or kde, have a 'trash' folder, so you can 'undelete' from it. The shell 'rm' commands are pretty close to final. That's why God invented SVN
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recovery of file after removing it?
 
Similar Threads
Restoring Files after removing using "rm" command.
how toremove files or directory in unix with name of special characters
recovery after rm command
Why "cat" command is known as "cat"?
How to delete the file with space in name?