LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

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


Hi
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.

Regards...
 
Old 08-27-2009, 10:51 AM   #2
kdelover
Member
 
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.

http://www.osscamp.in/blog/how-recov...command-ext3fs

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

Last edited by kdelover; 08-27-2009 at 10:53 AM.
 
Old 08-27-2009, 11:31 AM   #3
w1k0
Senior Member
 
Registered: May 2008
Location: Poland
Distribution: Slackware (personalized Window Maker), Mint (customized MATE)
Posts: 1,309

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

Code:
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, 12:49 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
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:
Code:
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, 01:00 PM   #5
kdelover
Member
 
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, 01:10 PM   #6
omraj
LQ Newbie
 
Registered: Aug 2009
Posts: 3

Original Poster
Rep: Reputation: 0
thanks

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.

thanks...
 
  


Reply



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 02:23 PM
How to recover deleted files? SentralOrigin Linux - General 11 01-25-2007 06:31 PM
how to recover deleted files sibtay Linux - Software 13 01-22-2005 08:09 PM
Recover deleted files? subaruwrx Linux - Newbie 8 06-04-2004 08:47 AM
Recover deleted files markdw Linux - General 1 12-07-2001 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:38 AM.

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