Skip to content

File Recovery Help

Featured Replies

Hi all,

I have been having issues with a Linux installation recently (Linux Mint, basically Ubuntu with media stuff pre-loaded). Anyway, one of the outcomes of the issue is that my uni coursework has become corrupted. The file was a programme file which was written in gedit, saved a in .c format then compiled using gcc within the terminal into an executable. If I try and run the programme it works, BUT I can't see the source code and the original C file only displays one line under Linux, or lots of 'null' symbols under Windows 7. Is there either anyway the file can be recovered, or that I can view the source code of the file?

Any help gratefully received,

Joe

What file system are you using on the drive?

To be honest I think it sounds like you'll need the backup unless you made a lucky choice on the file system.

Also worth checking for other versions hidden away with an ls -la | grep -i <filename without extensions>

If push comes to shove you can always decompile your executable and then tweak the code back to something useable and add the comments back in.

EDIT: You say you can only see one line.

Are you sure it's not just one very long line, which was opened in windows, saved and the white space stripped out?

Perhaps it has been encoded in a character system that windows doesn't understand (UTF-16?)

Edited by cheezemonkhai

  • Author

Thanks for replying.

It's an ext4 filesystem. Problem is I don't have a backup (I know, I know!) or not a non-corrupted one anyway.

The grep search drew nothing at all, which doesn;t surprise me. :(

Is it easy to decompile it, or is that going to be a pain in itself?

Edited by TriggerFish

Thanks for replying.

It's an ext4 filesystem. Problem is I don't have a backup (I know, I know!) or not a non-corrupted one anyway.

The grep search drew nothing at all, which doesn;t surprise me. :(

Is it easy to decompile it, or is that going to be a pain in itself?

Ahh Ext4, oops. It's good and all but depending on the version used I had some data loss issues. That was an early version, but nopt something I'd trust for essential storage just yet.

Do you know which kernel version you are running (uname -a)

Sure decompiling isn't hard to do at all, but it's immature for C unlike Java etc.

Also you won't end up with the original code, just something that does the same as the original code compiled down to.

You will then need to take that file and munge it by hand into something that is close to your original code and add comments.

If you have a print out etc, it 's probably just as easy to retype it.

This is one such decompiler, but it's not a very advanced version:

http://boomerang.sourceforge.net/download.php

Here is another which is from the house of hippies:

http://savannah.nongnu.org/projects/uncc/

  • Author

I take it it's still quite unproven long term them ext4? I don't tend to use Linux for much, and all the main data is saved on NTFS partitions, I just hadn't copied this over yet.:thumbdown:

Kernal is 2.6.31-14-generic (I think that's the right bit anyway). Pretty sure it's the latest one as I only installed/ burnt it a week or two ago.

I don't have any print outs or anything for it - only just finished it when it had some errors with xsession logs filling the HDD up then it disappeared.

I'll try the decompilers, see what I get left with. Even if I have to retype it I guess it's something to base it on.

Thanks for your help thus far.

What does the following show:

wc [filename]

cat [filename]

strings [filename]

?

Also.... do an:

ls -lais in the directory where you worked on the file in gedit and look for hidden copies of it (they will start with a dot (.).

edit: I see this has been suggested.

so also try:

cd ~

find . -depth -print | grep \.c

and see what comes out.

Edited by foo

  • Author

WC = wc '/question1' (compiled one if I do it with the .c it says not found)

50 244 9962 /question1

cat (tried this already) = cat '//question1.c' (thats the source code)

#include <stdio.h>

strings = trings '//question1' (complied file) - (source code/ .c file gives the same as cat).

/lib64/ld-linux-x86-64.so.2

__gmon_start__

libc.so.6

__isoc99_scanf

puts

printf

__libc_start_main

GLIBC_2.7

GLIBC_2.2.5

fff.

fffff.

l$ L

t$(L

|$0H

Rectangle Co-ordinates Programme

...displays the commands that are printed (prinft command in source code)

Tried the ls -la grep finder thing again, and it tells me that the binary file (Which works) is a match, but I need the actual code to submit.

Tried it narrowing down to c files as suggested, it found loads for the entire installation, but none at all when narrowed down to my work folder. Which seems odd considering I used (assuming they're still there) to have some others in their from previous work,

Thanks for the suggestions, if nothing else works I at least have the output from the programme and can run it so can use that as a basis for re-doing to work.

FWIW gedit seems to save temp files with an appended ~ (tilde)..... if there is no remaining temp file then you might be goosed. gedit can also be configured to save backups of files... might be worth considering.

  • Author

Ah, will look for those, then if nothing, redo it and set it to backup!

The decompilers I couldn't get working as my internet is playing up and is struggling to load anything, even google and simple pages.

Ah well, live and learn I guess! Thanks though.

My hot tip, for work like this ditch mint linux.

Install Opensolaris and setup the auto-snapshot thing, it is not a backup, but will let you recover previous versions of a file.

Or... run subversion.

  • Author

To be honest, I didn't intend of having to do this sort of work, but I just given it as a module at uni (doing networking, so I didn't assume I would need to be programming that much - got maths as wellemoticon-0106-crying.gif). Not really a massive fan of Linux on the whole, but I prefer this (Mint) for general use as lots of media stuff comes preconfigured. Only got a few more weeks of needing to do Unix work anyway. If this sorta work increases, I will consider a different version I reckon.

It was either this, or an emulator in Windows.

A Virtualbox setup is a good solution, you can then just snapshot and rollback as you go.

I would consider getting to know Unix a bit better if you are serious about networking, afterall you can run all the major routing protocols on Linux with open source product and you have much better access to network interfaces than on Windows.

Unless networking at uni is all about http, cifs, WINS and other such stuff.

  • Author

Don't think my 1.2Ghz CPU would like a virtual box much!

So far we are getting used to the thoery of the protocols (only just into my 2nd term) and getting used to the Cisco IOS and static routes etc. From next year we will need to start using UNIX a lot more, and I'll concentrate on it then, focus my time on the subjects I'm doing at the minute.

Networking on my course can vary depending upon the modues I choose. Next year covers;

Network Construction & Administration

Multi-Service Networks

Computer and Network Security

Then I can choose WAN + LAN security

Mobile Comms

Optics and Broadband

(whatever these entail)

We're doing the CCNA as well at the minute. Not too sure how we got this off topic, but at least it's my own thread we've hi-jacked.

TBH, that sounds a good course.

See if you can do the CCDA in Y3 - that was one of the best courses I ever did.

High level course then , so I shouldn't worry too much about trying to get into anything that makes you roll it yourself.

Regarding your lost file... you any good with inodes and a hex editor if you've got a previous version saved anywhere ;)

  • Author

Nice to hear approval of the course from thoes in industry, rather than promotions from the (unsurprisingly) biased university.

Will bear the CCDA course in mind, but got a long way to go until then!

Regarding your lost file... you any good with inodes and a hex editor if you've got a previous version saved anywhere ;)

TBH, I wouldn't have the first idea where to start or anything with those! Thanks though. I've just retyped it now based upon the output from the strings command and the output from the executable. Thanks for all help though.

Should have used Windows. Linux is for smelly weirdos.

Hope that helps. :thumbup:

Edited by wega3k

Nice to hear approval of the course from thoes in industry, rather than promotions from the (unsurprisingly) biased university.

Will bear the CCDA course in mind, but got a long way to go until then!

TBH, I wouldn't have the first idea where to start or anything with those! Thanks though. I've just retyped it now based upon the output from the strings command and the output from the executable. Thanks for all help though.

LOL.

printf "result!"

* I am not a coder

  • Author

printf("result!"); :giggle:

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Important Information

Welcome to BRISKODA. Please note the following important links Terms of Use. We have a comprehensive Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.