91 votes
Accepted

Wrong mv command. Where did my files go?

Your directory is still there :) You have renamed it .... Because files whose names start with . are hidden, you cannot see the directory unless you display hidden files run ls -A and there it ...
Zanna's user avatar
  • 3,571
90 votes
Accepted

I've just "mv"ed a 49GB directory to a bad file path, is it possible to restore the original state of the files?

When moving files between filesystems, mv doesn't delete a file before it's finished copying it, and it processes files sequentially (I initially said it copies then deletes each file in turn, but ...
Stephen Kitt's user avatar
66 votes

What are the contents of /bin/bash, and what do I do if I accidentally overwrote them

Don't shut down your machine. Do you still have a running shell? Is it bash? If so, you're fine. (But don't do this again.) Run: sudo cp /proc/$$/exe /bin/bash Voila, all is well. Since ...
Wildcard's user avatar
  • 36.5k
54 votes

Recover deleted files on Linux

What worked for me was given by arch (only applies to text files): grep -a -C 200 -F 'Unique string in text file' /dev/sdXN where /dev/sdXN is the partition containing the lost file (check with ...
William Becker's user avatar
51 votes

Accidentally ran sudo rm /* on my Arch Linux installation

Arch Linux has four symbolic links in /: bin -> usr/bin lib -> usr/lib lib64 -> usr/lib sbin -> usr/bin You should be able to recreate them (using a Live-USB or an emergency shell) or by ...
stefan0xC's user avatar
  • 1,538
50 votes
Accepted

How can I change a file to a directory? Files lost after find+mv

Adding a slash at the end of the destination path /opt/alfresco/archived/2020-01-07 would have made the mv command error out, as the 2020-01-07 directory evidently does not exist. This would have ...
Kusalananda's user avatar
  • 333k
48 votes
Accepted

Best practice to continue mv

Forget about trying to reinvent rsync, and use rsync. sudo rsync -av /location/to/drive1/ /location/to/drive2/ Make sure you use a trailing slash on the source, otherwise it would copy to /location/...
Gilles 'SO- stop being evil''s user avatar
41 votes

Wrong mv command. Where did my files go?

The correct form would have been mv folder_name ../.. You've moved your folder to a new folder named ....; to recover your files, run mv .... folder_name Like many other commands, mv is somewhat ...
Stephen Kitt's user avatar
39 votes

Why can't I copy my DVD with dd?

People mention that opening the DVD with VLC (which displays the DVD menu) magically makes the data accessible to dd, but nobody has yet explained why that is and how VLC accomplishes this feat. I ...
interfect's user avatar
  • 495
38 votes
Accepted

What are the contents of /bin/bash, and what do I do if I accidentally overwrote them

bash is a shell, probably your system shell, so now weird things happen, while parts of the shell are still in memory. Once you log out or reboot, you,ll be in deeper trouble. So the first thing ...
Philippos's user avatar
  • 13.4k
29 votes
Accepted

How to recover a broken mp4 file: moov atom not found

You can try and use Untrunc to fix the file. Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video. you may need to compile it from source, but ...
Rabin's user avatar
  • 3,883
27 votes

Recover deleted files on Linux

Recovery Tools - Command Line: testdisk - open source, dir-structure photorec - open source, NTFS extundelete - open source Recovery Tools - GUI: R-Linux - proprietary, free, dir-structure R-...
intika's user avatar
  • 14.4k
22 votes

How to mount/recover data on a disk that was part of a mdadm raid 1 on another machine?

This is working excellently in Ubuntu 14.04: sudo -i mdadm --assemble --scan You will get: mdadm: /dev/md/1 has been started with 1 drive (out of 2) Then mount and see your files: cd /mnt &&...
vchepurnov's user avatar
21 votes

I've just "mv"ed a 49GB directory to a bad file path, is it possible to restore the original state of the files?

After getting Stephen Kitt's answer and discussing this command as a potential solution: sudo mv -i ~/my_data_on_60GB_partition/* /media/admin/my_data/ I decided to hold off on running it until I ...
the_velour_fog's user avatar
19 votes
Accepted

Using ddrescue to shred only rescued portions of disk

The manual gives you an example which is almost exactly what you want: When ddrescue is invoked with the option --fill-mode it operates in "fill mode", which is different from the default &...
Kamil Maciorowski's user avatar
18 votes
Accepted

Read past end of file to recover data

Usually when editors save files, they delete or truncate to 0, thus freeing allocated space, and then write, which allocates new space. This results in the filesystem putting the data in a completely ...
frostschutz's user avatar
18 votes
Accepted

How to mount and de-encrypt a LUKS encrypted partition to recover files

To recover your files you will first need to open your LUKS container. This will make your LVM logical volumes accessible. Then, you can mount the appropriate logical volume to gain access to the ...
Emmanuel Rosa's user avatar
17 votes

Recover deleted files on Linux

Although this Question is solved and a few years old, I want to mention the testdisk utility. How to recover files with testdisk is explained well in this tutorial. To recover files run testdisk /...
NoUmlautsAllowed's user avatar
17 votes

Why does photorec keep finding files after I have filled the disk free space as root?

There may be several misunderstandings here, so the command does not do what you perhaps expect it to. sudo is superfluous since you don't need sudo to read from /dev/urandom. The > some-file part ...
frostschutz's user avatar
17 votes
Accepted

Undoing wipefs --all --force /dev/sda? /dev/sda

You're lucky that wipefs actually prints out the parts it wipes. These, wipefs -a /dev/sda /dev/sda: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54 /dev/sda: 8 bytes were ...
ilkkachu's user avatar
  • 138k
16 votes
Accepted

Overwritten LUKS with a partition table

cryptsetup repair, Part Two — Full Header Recovery See also: cryptsetup repair, Part One — Magic Bytes Recovery In order to recover a partially overwritten LUKS2 header, you need at minimum two ...
frostschutz's user avatar
14 votes
Accepted

How to recover xfs data after rm?

I deleted a python file that I knew had a specific fairly unique string in it. So I did the following: $ sudo strings -td /dev/mapper/vg01-lv_opt | grep "class Team(" 8648365228 class Team(object): ...
rrauenza's user avatar
  • 734
13 votes

Can overwritten files be recovered?

Make sure you have enough disk space in /var/tmp or somewhere big. Try grep -i -a -B100 -A100 'a string unique to your file' /dev/sda1 | strings > /var/tmp/my-recovered-file where /dev/sda1 ...
AndyM's user avatar
  • 514
13 votes
Accepted

How can I safely recover deleted data from a USB flash drive?

Are there any secure UNIX tools to recover data, that was removed with rm, from a USB flash drive? Yes and, by the way, recovery of photos is one of the most common scenarios. The conditions you ...
Andrea Lazzarotto's user avatar
12 votes

Recover deleted files on Linux

An alternative may be using del instead of rm for deleting: http://fex.belwue.de/fstools/del.html del has an undelete function and works with any file system. Of course it is not a solution if you ...
Framstag's user avatar
  • 169
12 votes

DDRescue taking months but no errors?

If anyone is interested or comes across an archived version of this in a few years. I waited the two months, establishing a log file to resume copying. Twice it just started getting reading errors (...
KinaMan's user avatar
  • 301
12 votes
Accepted

Unable to untar file after tar error

On the line $ tar cvzf file.txt file.tar.gz you have asked to create a compressed archive of the file file.tar.gz, and that the archive should be called file.txt. You have simply swapped the two ...
Kusalananda's user avatar
  • 333k
12 votes

md raid5: "no valid superblock", but mdadm --examine says everything is fine

The stupidly simple solution: add --update=devicesize when assembling. I have no idea how, but apparently the partition size and the size that md remembered for this drive didn't match up anymore. ...
Wüstengecko's user avatar
12 votes
Accepted

Faster disk recovery (ddrescue running slow)

ddrescue has this option: -a, --min-read-rate=<bytes> minimum read rate of good areas in bytes/s If you specify it on your command line with a decent size like 10M, with any luck, ...
frostschutz's user avatar
12 votes
Accepted

Ubuntu recovery says "fsck from util-linux" and exits

The command I needed was fsck.ext4, e.g. fsck.ext4 -F This let me fix the disk issues and recover the system.
MHG's user avatar
  • 420

Only top scored, non community-wiki answers of a minimum length are eligible