Announcement

Collapse
No announcement yet.

How to Recover a Deleted File in Linux?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to Recover a Deleted File in Linux?

    "We all have often faced a problem where we have accidentally deleted some files in Linux, that we definitely regretted deleting off later on after we did not even found it in the trash. But what if we can recover them? In this article, we will discuss How we can recover a Deleted File in Linux."

    https://www.geeksforgeeks.org/how-to...file-in-linux/
    Using Kubuntu Linux since March 23, 2007
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    #2
    If one accidentally deletes a directory none of those methods will work.

    IMO, the odds of any of those methods, including foremost (which is in the repository), working on a single file, are next to nil. Also, searching /dev/sdaX for a deleted file might work IF the file is a text file whose contents can be read during the search. Images of other files look like hexadecimal garbage. For image files the start and end of the file has to be identified. The lsof (list open file) command assumes that the deleted file was being held open by an app or process when it was deleted, a not too common mistake. In the distant past I was asked to recover a person's master's thesis and the 1500 photos and documents that were part of it from a disk that wouldn't boot. I mounted the disk and used photorec to recover all but 5 of them and the thesis. I was lucky.



    If one is using BTRFS or ZFS or another backup utility then it is possible to search a backup and extract copy the deleted file back to the file system. I've used mc many times to recover a file I accidentally deleted from my system. I mount my ROOTOS to /mnt and then locate the file in /mnt/snapshots/@yyyymmddhhmm/somepath and copy it back to my system. Since I began using BTRFS I have never lost a file or a directory that I accidentally deleted.


    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment

    Working...
    X