3

I did something real dumb. I was creating tarballs of files in my /var/ folder. The tarball i created was put into /tmp/test.tar

In the process of testing the extraction process, I meant to delete /tmp/var/ but ended up doing a

rm -r on /var

via the command line.

I know... ugh.

The good news is that I only had apache2 / php5 running on this test box. But I'm wondering if there's an easy way to recover my files? From what I've read so far in other posts, the answer is no. I'm trying to reinstall apache and php5 but of course, I'm getting errors. I have another Ubuntu box with a similar set up... so I copied over /var/lib/dpkg folder which got me a little further...

But now when i do an apt-get install apache2, I get the following error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package apache2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'apache2' has no installation candidate

I'm relatively new to Linux and am not so saavy , as you can tell! Just wondering if you had any tips on a quick recovery?

Thanks.

EDIT 1

I ran

sudo apt-get update

and it seemed to run properly.

Then I tried

$ sudo apt-get install apache2    
Reading package lists... Done 
Building dependency tree        
Reading state information... Done 
Some packages could not be installed. 
This may mean that you have requested an impossible situation or if you are
using the unstable distribution that some required packages have not
yet been created or been moved out of Incoming. The following
information may help to resolve the situation:

The following packages have unmet dependencies:  
apache2 : 
Depends: apache2-bin (= 2.4.7-1ubuntu4.1) but 2.4.10-1ubuntu1 is to be installed
Depends: apache2-data (= 2.4.7-1ubuntu4.1) but 2.4.10-1ubuntu1 is to be installed 
E: Unable to correct problems, you have held broken packages.

So I tried to do the following:

test@testpc:/$ sudo apt-get install apache2-bin 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apache2-bin is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.

test@testpc:/$ sudo apt-get install apache2-data
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apache2-data is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.

As you can see, it's not upgrading... Any other suggestions would be appreciated.

EDIT 2

I checked the box where I copied /var/lib/dpkg from and it's running ubuntu 14.10 whereas this one is running 14.04. Does that matter?

9
  • Did you run apt-get update?
    – muru
    Feb 17, 2015 at 16:02
  • drats. I should have thought of that. I did a sudo apt-get remove on apache2. but I will run that command anyways... to see if it helps. Please see my section called EDIT 1 for results
    – dot
    Feb 17, 2015 at 16:06
  • I think the copied dpkg data is misleading your new system into thinking it has newer versions of apache2-bin and other things installed.
    – muru
    Feb 17, 2015 at 16:14
  • 2
    Yes. Of course it matters. They're two different releases with different versions of packages.
    – muru
    Feb 17, 2015 at 16:30
  • 2

2 Answers 2

4

You've got 2 possibilities:

  1. Restore your System Back-up (you're definitely user type 4)
  2. Reinstall and start making System Back-ups

There! Yhat's it. Those are the 2 quick fixes for your system.

Anything else will lead to a lot of headaches, problems cropping up in a few days, weeks, months or even years!

1
  • 1
    yep. i agree. i've just decided to start clean... this was supposed to just be a "test" box ... but it's grown into something more.. So i'm reinstalling everything clean... and will back up.
    – dot
    Feb 17, 2015 at 18:03
0

It happened to me once, and something stupid actually solved it. I tried to update and it complained about missing /var/dpkg/ or whatever, I just created that missing directory or file and kept repeating apt-get update. Later I encountered this error message: dpkg: error processing some-package (--configure): and this answer helped me, whenever that error occurred, I just replaced install ok whatever with install ok installed. Now, this, of course, could be dangerous and might mess things up, but if reinstalling the OS is the only choice you are left with, then why not try this as a penultimate resort? And by the way, keep also trying to clean, autoclean and autoremove. So the steps are something like this:

sudo apt-get updte

the error message says: blah/blah/blah file/directory doesn't exist, just go ahead and create those directories/files (empty of course) and repeat the update process. When you encounter, for example,

dpkg: error processing some-package (--configure): dependency problems - leaving unconfigured

edit this file: /var/lib/dpkg/status

and find :

Package: some-package Status: install ok whatever

replace whatever with installed and repeat sudo apt-get update. Keep doing this until you are happy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .