69
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 ...
51
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 ...
26
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-...
25
votes
What's the fastest way to remove all files & subfolders in a directory?
rsync is surprisingly fast and simple. You have to create empty directory first,
mkdir emptydir
rsync -a --delete emptydir/ yourdirectory/
yourdirectory/ is the directory from where you want to ...
25
votes
Accepted
What's the fastest way to remove all files & subfolders in a directory?
The fastest way to remove them from that directory is to move them out of there, after that just remove them in the background:
mkdir ../.tmp_to_remove
mv -- * ../.tmp_to_remove
rm -rf ../....
23
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,...
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 ...
17
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 ...
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 /...
13
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/....
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 ...
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 "...
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.
...
10
votes
What's the fastest way to remove all files & subfolders in a directory?
The fastest is with rm -rf dirname. I used a snapshotted mountpoint of an ext3 filesystem on RedHat6.4 with 140520 files and 9699 directories. If rm -rf * is slow, it might be because your top-level ...
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 ...
9
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 ...
9
votes
What's the fastest way to remove all files & subfolders in a directory?
One problem with rm -rf *, or its more correct equivalent rm -rf -- * is that the shell has first to list all the (non-hidden) files in the current directory, sort them and pass them to rm, which if ...
9
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 ...
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 ...
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 ...
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 ...
7
votes
Recover deleted files on Linux
I had the same problem last week and I tried a lot of programs, like debugfs, photorec, ext3grep and extundelete. ext3grep was the best program to recover files. The syntax is very easy:
ext3grep ...
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 ...
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 |...
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 ...
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>)
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 ...
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 ...
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-...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
deleted-files × 128data-recovery × 31
linux × 25
files × 16
rm × 13
bash × 7
filesystems × 6
disk-usage × 6
delete × 6
open-files × 6
shell-script × 5
debian × 5
shell × 5
rsync × 5
macos × 5
ubuntu × 4
centos × 4
linux-mint × 4
directory × 4
btrfs × 4
ntfs × 4
extundelete × 4
command-line × 3
permissions × 3
find × 3