Recently I accidentally deleted my xmonad.hs
file which I've worked on for so long. I had no back up or a Trash folder whatsoever. I searched for a file recovery software that would bring back my config file. I took a look at Arch Linux's File Recovery wiki to try out the ones they've listed.
The first software I tested was Extundelete unfortunately it seems to require me to unmount the device although the file resided on the same partition where my OS is so I didn't seem to work out for me.
I also tried searching for a Windows program to recover files from an ext4 partition but unfortunately never found one.
The next was PhotoRec which did it for me.
Here are some screenshots on the steps I did for recovering the deleted file (most are similar to the screenshots found in PhotoRec's Step by Step guide):
I'm not certain which to check in the sixth step though. I've only selected Free as I believe it would be fast searching there. In the seventh step, it was required to select a different partition to where to store the recovered files. After the search was complete you'll find the folders recup_dir.* in the directory to where you chose to save the recovered files. It would somehow look like this:
I then just did a simple command to search for my xmonad.hs
latest config file (I had import Xmonad.Layout.Gaps
on my latest config):
find . -name "recup_dir.*" -exec grep -iR "xmonad.layout.gaps" '{}' \;
Now I have my config back! 8) It wasn't really the latest one but rather the latest one recovered by PhotoRec. :D