1

I accidentally mv a new file to an existing file and overwrote it. Is there anyway to undo mv or recover the replaced file?

1 Answer 1

1

The rm and mv and cp commands do not have an "undo" feature. They have some protections (like optional interactive confirmation).

If you mv a file or directory, it may be possible to recover the older contents using a data recovery application like testdisk or photorec. However, it requires learning and skill and patience to use those applications properly. Recovery is not easy and not certain. This is a last hope, and often forlorn.

Since all humans make mistakes, we encourage the use of backups to prevent frustration and despondence. Backups are much easier than data recovery.

1
  • 1
    "using a data recovery application like testdisk or photorec" — I would add that if OP indeed opts for such direction while not being familiar with these tools, then they would best need to shut down the PC, and use another OS on another disk to learn the operation of these recovery tools. (If available, booting from a Ubuntu Live USB is sufficient, as it, by default, leaves the internal disk alone.) The more usage the impacted disk sees after the problematic file operation, the more chance emerges that the desired data records will be further decimated, thus less hope remains for recovery.
    – Levente
    Dec 24, 2022 at 0:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .