Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-27-2009, 11:44 AM   #1
LQ Newbie
Registered: Aug 2009
Posts: 3

Rep: Reputation: 0
how to recover files taht got deleted by rm -ef * ?

Probably this is old questions, but didnt find the exact one.

I deleted files very inportant (.pdf,.gif, .jpeg etc) from my pen drive accidently.
OS: Linux AS 4.
file system ext3.

Command used : rm -rf *

Is there any way to recover it?

thanks in advance.

Old 08-27-2009, 11:51 AM   #2
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
if am not wrong you can recover them if you are under ext2 ( am not so sure about this ) when you do rm ,the file contents are not actually deleted ,they are still on your HDD its just the link that is deleted. Its always best to have a hardlink of your important data,so that if one file is deleted by mistake,the contents of the file can be still access via the other link.

See this if it helps,i never tried it myself.

Last edited by kdelover; 08-27-2009 at 11:53 AM.
Old 08-27-2009, 12:31 PM   #3
Senior Member
Registered: May 2008
Location: Poland
Distribution: Slackware, Mint
Posts: 1,252

Rep: Reputation: 205Reputation: 205Reputation: 205
First use dd to copy pen drive contents to a file on your hard disk:

mkdir /root/pendrive
dd if=/dev/sda1 of=/root/pendrive/pendrive.img
(Before running that command assure what device uses your pen drive).

Next try PhotoRec to recover data from pendrive.img file.
Old 08-27-2009, 01:49 PM   #4
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,087

Rep: Reputation: 407Reputation: 407Reputation: 407Reputation: 407Reputation: 407
mkdir /root/pendrive
That should give him a "Permission Denied" (and this is his first post to LQ)

But it's a very good idea to take an image before you start playing with recovery tools (because your pendrive is un-written to, and therefore untouched by "recovery" tools )

A better way to do it might be:
dd if=/dev/sda1 of=~/pendrive.img                # copy the data over, bit-by-bit , so you have an image
mkdir ~/pendisk                                  # create a mountpoint for the image at /home/omraj/pendisk
mount -o loop -t ext3 ~/pendrive.img ~/pendisk   # mount the image
* ext3 will have to be changed if your pendrive's filesystem isn't ext3 ( most are FAT32 or type vfat - see man mount )

Now the image is mounted at ~/pendisk just as if it was a real disk. Run your recovery tools on that. If you mess up, you can always re-image your pendrive ( dd if=/dev/sda1 of=~/pendrive.img ) and start again.

Welcome to LQ!
Old 08-27-2009, 02:00 PM   #5
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
So is it possible to recover something that has been rmed ?? Nice info w1k0 and tredger.
Old 08-27-2009, 02:10 PM   #6
LQ Newbie
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0

Thanks to all.

But i am still unable to recover the file.

The error is

0 files saved in /home/recovery/recup_dir.
cannot create file in current durectory.
i have given 777 file permissons.
Can any one help please.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
recover deleted files ashishjen Linux - Newbie 5 02-02-2007 03:23 PM
How to recover deleted files? SentralOrigin Linux - General 11 01-25-2007 07:31 PM
how to recover deleted files sibtay Linux - Software 13 01-22-2005 09:09 PM
Recover deleted files? subaruwrx Linux - Newbie 8 06-04-2004 09:47 AM
Recover deleted files markdw Linux - General 1 12-07-2001 05:08 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration