LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-14-2010, 09:29 PM   #1
sirpelidor
Member
 
Registered: Oct 2003
Location: Madison
Distribution: mdk 8.2, 9.0, 9.2, slack 9.1
Posts: 403

Rep: Reputation: 30
HELP!!!! i accidentally deleted my home directory


Hey guys, I accidentally deleted my home directory.. it contains some very important software I've been programing since Feb... I'm freaking out right now, and try to google around for solution, but there are too many answers to diff type of recovery and i'm not in a stable mind to understand whatever i'm reading off the web...

detail story:
I was zipping a file from my /var/www folder and get ready to move to my home dir this afternoon:

1) pwd: /var/www/
2) sudo zip -r mysite.zip mysite/
3) sudo mv mysite.zip /home/myDir .
4) home dir gone.....


i dunno wtf i was thinking... why did i put a period at the end of the command... i wanna kick myself in the balls right now... anyway... this happened on a Ubuntu HardyHeron 8.04LTS

Please help, i google there are some app call scalpel or R-Linux, but i dunno...it doesn't seem like its recovering from delete folder...rather it tries to recover from damages partition? i dunno...i can't understand whatever i'm reading off the web now, everything suddenly becomes very complicated.

Thank you your help in advance!!!

p.s:
after i issued that sudo mv mysite.zip /home/myDir . command, i can't do anything on Gnome... can't issue firefox, can't do anything, and the screensaver just kicked in, and i'm unable to go back into the system...

i'm a freaking idiot...
 
Old 07-14-2010, 09:37 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
It is not obvious to me why that syntax would delete the home directory----but that's another story.

The first thing I would do it boot up from LiveCD and see what is on the disk.

If you don't do anything that would cause a write to the disk, then your data is still there. The most commonly-recommended tools are photorec and testdisk---both from the same author---or you can engage a professional recovery service.
 
Old 07-14-2010, 09:45 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I just ran a quick test:

This command moves the two files / direcotries into the current directory:

Code:
mv <path1> <path2> .
Based on this, I'd say your data is probably intact. The reason things are screwed up is that various config files are no longer where the system expects to find them.
 
Old 07-14-2010, 09:52 PM   #4
Elv13
Member
 
Registered: Apr 2006
Location: Montreal,Quebec
Distribution: Gentoo
Posts: 825

Rep: Reputation: 129Reputation: 129
If your data is really deleted, check your e-mails (I tried the LQ emailer proxy, I don't know if it work). It helped me in the past (referring to the content of the e-mail, itself referring to some proprietary softwares (that work better than photorec/foremost/sleuthkit) ).
 
0 members found this post helpful.
Old 07-14-2010, 09:58 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by Elv13 View Post
If your data is really deleted, check your e-mails (I tried the LQ emailer proxy, I don't know if it work). It helped me in the past (referring to the content of the e-mail, itself referring to some proprietary softwares (that work better than photorec/foremost/sleuthkit) ).
I'm not sure what you are talking about.....who was e-mailing you this information?
 
Old 07-14-2010, 10:47 PM   #6
sirpelidor
Member
 
Registered: Oct 2003
Location: Madison
Distribution: mdk 8.2, 9.0, 9.2, slack 9.1
Posts: 403

Original Poster
Rep: Reputation: 30
Pixellany,

thank you thank you thank you thank you thank you thank you thank you thank you for pointing out that mv didn't deleted my home dir

i just booted into recovery mode, sure enough!!!! my home directory is sitting at /var/www !!!!!!!

been using linux for quite a while, i should've know mv (source) (source) (dest) won't get my files (folder) deleted.

I guess it just one of those thing that when one is in the freaked out mode...he can't think straight ....

Thank you very much, now i'm back to work...and this is a good learning lesson... I need to backup my crap in a regular basis...!!!!!

a note for myself as well as everything who read this post:

if you do software development on ur laptop, try do the followings...
1) backup ur laptop
2) setup a separate box as svn server, so every revisions will be saved
3) if u r a java developer, try setup a maven repository on that separate box also, so you won't need to worry about jar's versions when trying to recover from a broken machine
4) backup that separate box


Thank you !!!!!!
(time to grab a drink!!!)
 
Old 07-15-2010, 05:24 AM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Only 'rm' 'dd' and sometimes 'cat' can delete files, the rest of the commands cannot delete files. (there may be a few other exceptions) I personally have made safe versions of rm and dd, for personal use as root, that use blacklists of files and directories that should not be deleted.
 
Old 07-17-2010, 04:03 AM   #8
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by Grasa View Post
I've just read the whole post. ... SPAM
I'll bet you did you dirty little spammer, you have been reported, and hopefully will be banned.
 
Old 07-18-2010, 07:55 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by H_TeXMeX_H View Post
Only 'rm' 'dd' and sometimes 'cat' can delete files, the rest of the commands cannot delete files.
I thought that mv and cp will overwrite wiles without asking, unless you used the right options.
 
Old 07-18-2010, 09:39 AM   #10
wagaboy
Member
 
Registered: Jun 2010
Distribution: Ubuntu 10.04, Cent OS 5.5, CLE3
Posts: 51

Rep: Reputation: 21
Quote:
Originally Posted by MTK358 View Post
I thought that mv and cp will overwrite wiles without asking, unless you used the right options.
It is possible to alias these commands with interactive option set(-i) which asks you to decide if a file is going to be overwritten to prevent users from accidentally deleting files. This is usually set by administrators.
 
Old 07-18-2010, 10:28 AM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
But still H_TeXMeX_H said that no other command (including mv and cp) can possibly overwrite files.
 
Old 07-18-2010, 03:33 PM   #12
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by MTK358 View Post
I thought that mv and cp will overwrite wiles without asking, unless you used the right options.
Yes, these are the other exceptions I was referring to. But, this is a special case, because it doesn't delete, but rather overwrite.
 
Old 07-18-2010, 04:12 PM   #13
fbsduser
Member
 
Registered: Oct 2009
Distribution: Hackintosh, SlackWare
Posts: 267

Rep: Reputation: 30
For recovering deleted files/partitions you can use testdisk (to recover partitions) and photorec (to recover files). But one important thing to remember STOP USING the disk as soon as you realize that you deleted stuff you didn't intend to delete. As you keep using the disk new data starts overwriting the places where the deleted data is, which makes recovery harder or impossible.
 
Old 07-19-2010, 03:53 AM   #14
Davno
Member
 
Registered: Mar 2004
Location: Montreal, Canada
Distribution: Linux MX 23 KDE "Libretto"
Posts: 213

Rep: Reputation: 25
Quote:
Originally Posted by H_TeXMeX_H View Post
I personally have made safe versions of rm and dd, for personal use as root, that use blacklists of files and directories that should not be deleted.
I did not think of that, can you give me a hint on how to do it, and also the way to override that if i really want to delete a blacklisted directory.
Thanks
 
Old 07-19-2010, 04:27 AM   #15
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Well, these are the current versions of each:

sdd
Code:
#!/bin/sh
# implement safer dd using blacklist

# location of blacklist
blacklist=/home/$USER/.ddblacklist

# if blacklist does not exist
if test ! -e "$blacklist"
then
  ls -1l /dev/disk//by-path/ | sed '1d' | awk '{ print $10 }' | sed 's|../..|of=/dev|g' > "$blacklist"
fi

# parse blacklist
for i in $@
do
  if grep -x "$i" "$blacklist"
  then
    echo "Error, bad idea, remove $i from blacklist if you don't think so, and try again !"
    # fail
    exit 1
  fi
done

# run dd
if dd $@
then
  # success
  exit 0
else
  # fail
  exit 1
fi
srm
Code:
#!/bin/sh
# implement safer rm using blacklist

# location of blacklist
blacklist=/home/$USER/.rmblacklist

# if blacklist does not exist
if test ! -e "$blacklist"
then
  find / -type d -maxdepth 2 > "$blacklist"
fi

# parse blacklist
for i in $@
do
  if grep -x "$i" "$blacklist"
  then
    echo "Error, bad idea, remove $i from blacklist if you don't think so, and try again !"
    # fail
    exit 1
  fi
done

# run dd
if rm $@
then
  # success
  exit 0
else
  # fail
  exit 1
fi
's' is for safe. They automatically generate a reasonably sane blacklist. You can improve on them if you have a better idea. I've tested them and they seem to work ok.
 
  


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
I just accidentally deleted my /tmp directory Daedra Slackware 3 05-30-2009 09:19 PM
Deleting home directory of deleted user Nemesissparadise Linux - Newbie 3 04-16-2009 11:06 AM
Home Directory & C drive deleted at same time Wen Win Linux - Newbie 1 12-17-2005 06:53 AM
help, accidentally deleted /root directory ahimsel08 Linux - Software 6 07-01-2004 02:02 AM
Mandrake 9.2 deleted my home directory on an upgrade. bolinux Mandriva 5 11-18-2003 06:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:27 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