Skip to main content
70 votes
Accepted

I just deleted everything in my home directory. How? And why are some files still there?

Ouch. You aren't the first victim. What went wrong? Starting in your home directory, e.g. /home/felix, or even in /home/felix/src or /home/felix/Downloads/src. cd ../Dependencies/cpython Failed ...
Gilles 'SO- stop being evil''s user avatar
55 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
28 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.6k
22 votes
Accepted

macOS rm command '-W' option - undelete

A whiteout is a special marker file placed by some "see-through" higher-order filesystems (those which use one or more real locations as a basis for their presentation), particularly union filesystems,...
Michael Homer's user avatar
20 votes

How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)

As mentioned by terdon, when writing to a "foreign" filesystem, Mac OS uses two filenames for each file. One with the actual contents and a second one with metadata that would have been ...
Ángel's user avatar
  • 3,574
18 votes

Best way to free disk space from deleted files that are held open

As others have said lsof can be used to list all the deleted files which are still on disk due to open file descriptors. However, this may be a very long list. Here is a command which lists these ...
jcoffland's user avatar
  • 329
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
15 votes
Accepted

How can I restore my default .bashrc file again?

There exist backup copies of .bashrc, .profile etc. in /etc/skel/. So one could replace a corrupt .bashrc simply by overwitting from there. How do I restore .bashrc to its default? cp /etc/skel/....
Z0OM's user avatar
  • 3,189
12 votes

macOS rm command '-W' option - undelete

A "whiteout" is a feature of some union filesystem. If you have a file hierarchy that is overlain by a union mount, and a file exists in both layers of the resulting visible file hierarchy, a "...
Kusalananda's user avatar
  • 339k
11 votes

I just deleted everything in my home directory. How? And why are some files still there?

Tracing your cd calls, assuming we are running the script in ~/Distribution/Scripts and assuming that every cd succeeds: cd ../Dependencies/cpython We are now in ~/Distribution/Dependencies/cpython. ...
Kusalananda's user avatar
  • 339k
10 votes

undelete a just deleted file on ext4 with extundelete

extundelete core dumped for me but ext4magic is currently spewing out files: Unmount the filesystem immediately If that means shutting down your computer and attaching your disk to another machine ...
racitup's user avatar
  • 241
10 votes
Accepted

How to recover the deleted binary executable file of a running process

It could only be in memory and not recoverable, in which case you'd have to try to recover it from the filesystem using one of those filesystem recovery tools (or from memory, maybe). However! $ cat ...
thrig's user avatar
  • 35.1k
10 votes
Accepted

What happens when the current directory is deleted?

How comes that ls doesn't see the problem? There is no "problem" in the first place. something is not right in the terminal A There is nothing not right. There are defined semantics for ...
JdeBP's user avatar
  • 69.5k
9 votes

How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)

Now it's hard to recommend anything, but if I were you, I'd try using R-Studio Undelete - in my experience it's the best application for restoring accidentally deleted or damaged data from a number of ...
Artem S. Tashkinov's user avatar
9 votes

How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)

I'm afraid you have overwritten all of the original files. The ._ files are a special thing of macOS systems and HFS drives. From what I understand, they seem to be used to store things like the icon ...
terdon's user avatar
  • 245k
9 votes

How to recover “deleted” files in Linux on an NTFS filesystem (files originally from macOS)

If you haven't overwritten the files, you can trivially recover all of your files. If they are images, your best bet is to use a JPEG file carving tool. JPEGs are easy to carve because they are ...
vy32's user avatar
  • 194
7 votes

undelete a just deleted file on ext4 with extundelete

extundelete didn't work for me but ext4magic did. EDIT in 2022: extundelete hasn't been updated in almost 10 years. If you have a Windows partition, you can try Piriform's Recuva. Just don't let ...
Arnaldo Montoya's user avatar
7 votes
Accepted

Ignore 'cannot remove `dir`: Is a directory message

You can just throw away the error messages: rm * 2>/dev/null That'll throw away all errors. If you want to see other potential errors then we can do something more complicated: rm * 2>&1 |...
Stephen Harris's user avatar
7 votes

Recovering a file that is overwritten with cat >

As soon as you redirect the stdout of any command to myfile with any_command > myfile the system creates myfile; if there was another file with the same name, it gets overwritten. So your best ...
dr_'s user avatar
  • 30.1k
7 votes

How can I restore my default .bashrc file again?

There's a default bashrc file you can restore: cp /etc/skel/.bashrc ~ (equivalent of cp /etc/skel/.bashrc /home/<user>)
Peregrino69's user avatar
  • 2,467
6 votes

All my files have been erased after I tried to make my audio better

your mistake is here: rm -r ~/ .pulse there were no space between ~/ and .pulse on this website I believe. So, you effectively deleted all files in directory ~/ (your home directory) and in sub-...
Serge's user avatar
  • 8,651
6 votes

Recover deleted files on Linux

Recover deleted files with ext4magic sources to read: https://wiki.archlinux.org/title/File_recovery#TestDisk_and_PhotoRec Ext4magic is another recovery tool for the ext3 and ext4 file system. Be ...
Alban Kaperi's user avatar
6 votes
Accepted

unlink original file instead of symbolic link. What to do?

As the man page specifies, the unlink command will remove a specified file : UNLINK(1) NAME unlink - call the unlink function to remove the specified file Unlink will remove hard-links and ...
magor's user avatar
  • 3,772
6 votes
Accepted

rm -rf destroyed directories of the files set to be deleted (multiple arguments)

If the value of domain was empty or undefined, you just ran, e.g., rm -rf /var/www/html. You can check explicitly that domain is defined: if [ -z "$domain" ]; then echo "ERROR: domain is ...
larsks's user avatar
  • 35.9k
5 votes
Accepted

Restore deleted text file content

Solved it with help of the accepted answer here: Can overwritten files be recovered? For larger files that may be in multiple non-contiguous blocks, I do this: grep -a -b "text in the deleted ...
divandc's user avatar
  • 71
5 votes
Accepted

Restore part of a package that was accidentally deleted

You can use the --reinstall flag to apt-get apt-get --reinstall install procps
Stephen Harris's user avatar
5 votes
Accepted

View list of deleted files

You can use the debugfs utility, debugfs is a simple to use RAM-based file system specially designed for debugging purposes First, run debugfs /dev/sda2 in your terminal (replacing /dev/sda2 ...
Rahul's user avatar
  • 13.7k
5 votes
Accepted

Free space not reclaimed after truncating the fd

In fact the space is reclaimed by the filesystem, but the size of the file is only temporarily reduced to 0 until the next write by the process that still has the file open. At that point the size is ...
meuh's user avatar
  • 51.9k
5 votes
Accepted

How to see the contents of a file I deleted, but that a process is still writing to

The old file isn't yet gone, and you could access it if you know the PID of the process writing to it. You can go to /proc/<pid>/fd and look at 1 which is it's stdout This also means, though, ...
Eric Renouf's user avatar
  • 18.5k
5 votes

On Mac OSX, how can I open a deleted file which is still open by a process?

<EDIT> If this was Linux, you could also use a gdb trick. But it turns out we can rule out that trick on OS X, because it relies on Linux-specific behaviour of /dev/fd/ (/proc/self/fd/). That's ...
sourcejedi's user avatar
  • 51.1k

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