how to restore data after running rm? [duplicate]
I accidently ran sudo rm *
I thought I was in an unimportant subfolder.
The result is that I deleted some very important files. Is there any way to get my data back?
But I prefer foremost
Install foremost
sudo apt-get install foremost
Take a look at
man foremost
to learn how to use foremost.
First make an empty writable directory to save recover files in a partition other than that you are going to recover.
Then run foremost.
I am going to recover my home partition ( let's say /dev/sda5
).
$ sudo foremost -t jpg -i /dev/sda5 -o /recovery/data
Finally set user permission to /recovery/data/ to view image. type
$ sudo chown YOUR_USER_NAME /recovery/data -R
Some important foremost command line arguments.
-i :- partition/image to recover
-o :- location to store recovered files.
-t :- built in file filter options. you can give multiple filters by separating using commas. (e.g: for jpg and pdf: -t jpg,pdf )
-q :- quick mode.
After the steps from @2707974 above, then you can use this bash utility lines to browse millions of files quickly and painless, something like this:
`$ mkdir /recovery/filtered && cd /recovery/data && SKIP=1300 #SKIP value depends on your needs
$ for((j=$SKIP; j<10000; j=j+100)); do
for i in $(ls -S . | head -n $j | tail -n 100); do
cp $i ../filtered/;
done;
sleep 10;
rm ../filtered/*;
done`
And then now, you can open /recovery/filtered on your file browser, and watch your history...