Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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...
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.
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.
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) ).
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?
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
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.
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.
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.
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
#!/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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.