-   Linux - General (
-   -   recover home directory after userdel (

mr_sarge 11-27-2007 11:41 AM

recover home directory after userdel
Write me it's possible... pls :(

I've deleted the bad user and important data where in is home folder.

Is there a way to recover it ?


pljvaldez 11-27-2007 01:05 PM

Not sure if you can recreate the home folder or not.

But you might be able to recover the data by plugging the drive into another machine and using photorec and/or foremost. They're data recovery tools for when you accidentally mess up your drive or reformat it. But it should work here as well.

The only downside is that you have to manually sift through all the data and your filenames will be lost.

sundialsvcs 11-27-2007 07:56 PM

Here's the question: does /home/username still exist ... or not?

If userdel nuked that directory, then I am very sorry to say that ... yer scro-o-o'd... :rolleyes:

But if, by some happy happenstance, the directory does exist, then you can mv the files anywhere you want them to go, and chown them into the ownership of whomever you please.

mr_sarge 11-28-2007 07:00 AM

After some search, I've try "photorec". Lots of data where recovered but nothing that was in that folder.

I've also try a grep: "grep --binary-files=text -a50 -b300 "<?php" >/mnt/SomeNetwork"

This has recover most php file of this user in a huge 250mb text file ! Unfortunably, picture and all other file where lost but it's no big deal.

Thank you

H_TeXMeX_H 11-28-2007 07:31 AM

I've used foremost before and it's very good. Maybe try that, assuming while using photorec you didn't dump the recovered data to the same drive you were recovering from in which case you probably overwrote any other recoverable data.

pljvaldez 11-28-2007 11:51 AM


Originally Posted by mr_sarge (Post 2973254)
After some search, I've try "photorec". Lots of data where recovered but nothing that was in that folder.

Did you look at the data individually? All the filenames will have been lost and it will just have a generic filename. It finds photos especially well, but like I said, you can't just search a directory, it'll scan the whole hard disk. You'll even get images from your internet history...

mr_sarge 11-28-2007 12:07 PM

I've Switched the filter to only show up jpeg, gif, png and PSD.

8 hours remaining !!!

8000 file copied for now. I've found some that was in the user home folder.

I'll let it go...

pljvaldez 11-28-2007 01:10 PM

You are writing to a separate drive or partition, correct? Otherwise, the program will find the files it just copied over and over and over again. Not to mention it might overwrite some of the data you're trying to recover...

mr_sarge 11-28-2007 02:17 PM

i'm writing ont a network drive

mr_sarge 11-29-2007 08:43 AM


Just want to thank you all.

I have successfully recover majority of lost file. We now have a little job of find and rename files !!

Discovered something about photorec.

I have first search with default option (all filter on) and restored 35 000 files. Didn't get what we had lost.

I have then made another search with only gif, jpg, png and PSD filter on. recover 23 000 images. the want we need where in there.

After that, made an txt file search (txt, html, php) and recover 55 000 files for a total of 78 000 files compared to 35 000 the first time !

If you have to recover something with photorec, search seperatly for each type of file you need !

Good day


All times are GMT -5. The time now is 01:21 PM.