I accidentally deleted a directory with

rm -rf /media/directory 

When using

ls -lh /media

the space appears to be free, but when I use df or open the file manager nautilus or pantheon, it shows that the previously occupied space is still allocated.

I googled this problem and some says that some process is still using these data, so it won't be freed till unmount, restart or killing the process itself. I did none of these still, is there any way to recover it?

  • I did this too before, (sometimes must be the first one I guess?) Try a tool named foremost, to recover some files as a shortcut here: foremost -v -t <dir to recover or /device> I THINK I can be wrong, it was long ago I used foremost but I think that's it ; Hope it fixes itself! good luck - It's never fun to accid. delete stuff, trust me I've been there. – William Martens Dec 5 '20 at 15:08
  • i opened the computer to solely backup the directory that i deleted with rm -rf – polendina Dec 5 '20 at 15:18
  • The best thing to do is stop using the computer now, logout and boot up with a live USB or DVD and recover the files using foremost or testdisk / photorec (photorec recovers more than just photos). Ideally, it would be best to also have a spare USB storage device to dump the files onto. Using testdisk or photorec, the files (or pieces of the files that are left) will no longer have the original file names but the actual data (deleted files) may be recovered from the available free space (Select a directory on the USB storage for the recovered files). – mchid Dec 5 '20 at 16:53
  • I usually use photorec (which is included in the testdisk package) to recover deleted files and I select all the filetypes but I believe testdisk is supposed to be capable of undeleting files or at least recovering deleted files from the free space of the specified partition. See here for more information. – mchid Dec 5 '20 at 17:06
  • 1
    i wanna keep my computer up , as i aforementioned some people say there is a process using it , and that's why both the file managers and df is still reading the previously occupied space .... i was wondering if there is a way to recover the data instead of typical recovery – polendina Dec 5 '20 at 17:19

Browse other questions tagged or ask your own question.