PDA

View Full Version : [ubuntu] Deleted my home directory. How to recover?



Jimmy9pints
December 30th, 2008, 04:06 PM
Hi, I was having a couple of glitches with Ubuntu, and since my home folder was mounted on a separate partition I thought the quickest way to sort it out was to reinstall.

Everything went smoothly, except because I changed my username from "james" to "jam", my Documents, Pictures etc. were not where they should be. Instead there were two folders in the /home directory, named james and jam.

I thought the solution was simple, so I ran

sudo mv james jam

Which promptly removed my folder named james, but the jam was still empty. DAM! I don't know what happened!

Any help appreciated.

taurus
December 30th, 2008, 04:41 PM
Are you in a recovery mode or from the LiveCD?

Can you post the outputs of these commands?


ls -la /home
tail -5 /etc/passwd
tail -5 /etc/group

stderr
December 30th, 2008, 04:44 PM
By executing that command, you should have ended up with:

/home/jam
/home/jam/james

with all the files that were in /home/james now in /home/jam/james. I can't see how it would have removed any files... :|

Jimmy9pints
December 30th, 2008, 05:16 PM
By executing that command, you should have ended up with:

/home/jam
/home/jam/james

with all the files that were in /home/james now in /home/jam/james. I can't see how it would have removed any files... :|

Actually, yes you're totally right. I still haven't got to grips with the command line after 10months!

What should I do now?

stderr
December 30th, 2008, 10:27 PM
Well, if you just want all the files that were in 'james' to move to 'jam', and your setup is now like this:

/home/jam/james

I'd use


mv -r /home/jam/james/* /home/jam

This will recursively (also moving all subdirectories) move all the files & dirs in james to jam. Then you can just check there's nothing left in james, then remove that directory.


ls /home/jam/james

^^ That should now be empty


du --max-depth=0 -h /home/jam/james

^^ That should report ~4KB, depending on your block size settings (it should be reporting the size of 1 folder).


du --max-depth=0 -h /home/jam

^^ That should report a much larger size

So, you can remove the empty 'james' dir with


rmdir /home/jam/james

and you should be done.

Jimmy9pints
December 31st, 2008, 01:36 PM
Thank you kindly!

stderr
December 31st, 2008, 07:52 PM
You're welcome :)