Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-08-2006, 08:27 PM   #1
Registered: Nov 2003
Distribution: SUSE
Posts: 31

Rep: Reputation: 15
Recovering lost code/program

I was working on a program from a terminal when I fat-fingered a command and accidently deleted the entire directory . Although I have last night's save, I don't want to lose what I've done today.

I'm using a journalling filesystem, so I'm pretty much screwed in terms of undeleting the files - I'm not going to wait for raw search to find strings from my program sitting on a 100gb hard drive. However, I have one instance of the program still executing. Is there any way I can either recover it from memory and decompile (I only need to recover snippets of code I've worked on anyway) or make it do a core dump and recover data from that?

(PS: WTF will rm delete an entire directory structure without a peep?)
Old 03-08-2006, 09:35 PM   #2
Senior Member
Registered: Dec 2003
Posts: 3,161
Blog Entries: 4

Rep: Reputation: 136Reputation: 136
(PS: WTF will rm delete an entire directory structure without a peep?)
rm -rf will certainly delete directories recursively without confirmation. Very dangerous command.
Old 03-08-2006, 10:03 PM   #3
Registered: Nov 2003
Distribution: SUSE
Posts: 31

Original Poster
Rep: Reputation: 15
Not rm -rf...

I accidently entered "rm *?". Such a command should ask for confirmation, even without the -i flag. (One thing I like about the old MandrakeLinux... it effectively did that by aliasing rm to rm -i, which would have prevented what happened to me)
Old 03-09-2006, 04:26 AM   #4
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
on debian you have to uncomment this in ~root/.bashrc
# Some more alias to avoid making mistakes:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'
Another pretty dangerous is
Imagine you want to get rid of .files

cd <somedir>
rm -rf .*
bam .. is taken by .* , you're lost

In this case, depending on your FileSystem (how long it takes to write back to disk), one thing to do is pull the plug quickly or do a hardreset. For Ext3 you have 5seconds, for XFS you have longer.

Otherwise, if tool late, do not reboot and inspect /proc/kcore if you have it (make a copy to your disk). Depending on the amount of ram it will take you more or less time. You can also make a dump of your swap space to a file with dd for example.
If you have ext2, use unrm.

In anycase, do some backups, even on the same disk if you can't be bothered to use a cd writer. It will keep you safe from these mistakes.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
building source code, getting a little lost in it fognight Linux - Newbie 12 01-16-2006 02:01 PM
I lost my C source code y2j_2062 Linux - Software 1 09-24-2005 09:28 AM
Recovering Lost Data lawrencegoodman Linux - General 1 04-04-2004 01:57 PM
Recovering Lost Files gonus Linux - Software 1 08-08-2003 03:14 PM
Recovering Lost Admin. Password Mr Neroazzurri Linux - Security 4 03-14-2003 06:26 PM > Forums > Non-*NIX Forums > Programming

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

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