LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-08-2006, 07:27 PM   #1
The MCP
Member
 
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, 08:35 PM   #2
vharishankar
Senior Member
 
Registered: Dec 2003
Posts: 3,142
Blog Entries: 4

Rep: Reputation: 121Reputation: 121
Quote:
(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, 09:03 PM   #3
The MCP
Member
 
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, 03:26 AM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
on debian you have to uncomment this in ~root/.bashrc
Code:
# 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

Code:
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.
 
  


Reply


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 01:01 PM
I lost my C source code y2j_2062 Linux - Software 1 09-24-2005 08:28 AM
Recovering Lost Data lawrencegoodman Linux - General 1 04-04-2004 12:57 PM
Recovering Lost Files gonus Linux - Software 1 08-08-2003 02:14 PM
Recovering Lost Admin. Password Mr Neroazzurri Linux - Security 4 03-14-2003 05:26 PM


All times are GMT -5. The time now is 11:47 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration