I’ve been working on a Python project and had done quite an amount of coding when I decided to rename a few files. While doing this, the most important file, the one with the most code in it, got deleted. It was on a ReiserFS partition and I couldn’t recall any tool that I could use straightaway, before the data was overwritten with something else.
I got the whole file back, but it was done in a really simple way without the use of any fancy tools. I used less.
This is what I did:
- Opened the partition I was working on, using less:
less -f /dev/sda18
- Searched for some of the text that I remembered was in the file
- Realized that there were multiple “versions” of the data from the file I deleted (wonderful how Linux filesystems work)
- Recalled the last few variables I added to the original code and searched for those
- Copy + pasted the latest text that I found, into a new file
Amazingly, the file size, after copying and pasting, came out to be exactly the same as the original and there were no issues with the code. Thank God for less, UNIX and Linux. Will update on the Python project when it’s complete.