Hello, I start a new thread already knowing the solution, hoping that it will help someone having a similar problem.

I have overwritten a file with an empty one and managed to recover it with the following steps (use a terminal to carry out these operations):
  1. Do not remove the file overwritten. Just turn off the computer.
  2. Boot the computer with a live distribution. Once you have an operating linux OS, install "extundelete" (if not already present in your distribution).
  3. As root
    Code:
    sudo su
    mount in a temporary directory the partition containing the file to be recovered, e.g.
    Code:
    mkdir ~/tmp
    mount /dev/sda1 ~/tmp
  4. Remove the overwritten file, then unmount the partition.
  5. Connect an external drive and navigate to it.
  6. now you can recover the file, e.g.
    Code:
    extundelete /dev/sda1  --restore-file /path/to/file
    Note that /path/to/file is the original path of the file in the /dev/sda1 partition!


That's it! Hope you will succeed