Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Earlier, I had a problem with a package, and I (wrongly) ran this:

rm -r /var/lib/dpkg/*

See also my other question.

Now when I try to upgrade, I get this:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
masoud@masoud-PC:~$ sudo apt-get upgrade 
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

and when I use: sudo dpkg --configure -a

I get this:

dpkg: error: cannot scan updates directory `/var/lib/dpkg/updates/': No such file or directory

enter image description here

and for sudo apt-get upgrade -f get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... failed.
The following packages have unmet dependencies:
 ia32-libs : Depends: ia32-libs-multiarch but it is not installable
 wine1.4 : Depends: wine1.4-i386 (= 1.4.1-0ubuntu5) but it is not installable
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies
share|improve this question
    
Did you do something before this? When the problems started? –  Braiam Sep 11 '13 at 12:52
    
yes. when the package break, I do this: sudo rm -r /var/lib/dpkg/* –  Mj125 Sep 11 '13 at 13:02
    
Please, stop doing all sort of things behind our backs. Edit your question and include the 3 steps before the system broke and the steps you took (with results) to fix it. Don't run anything. In fact running any command with rm is destructive, and unless your asked to do so, do not use rm. –  Braiam Sep 11 '13 at 13:07
    
You will need to restore from backup or reinstall. –  psusi Sep 11 '13 at 14:11
1  
@Braiam, yes, if you have a backup of the status file in /bar/backup, you can restore that... and then reinstall every single package it lists... that still amounts to reinstalling, just doing it the hard way. –  psusi Sep 12 '13 at 1:45
show 8 more comments

4 Answers

When you ran

sudo rm -r /var/lib/dpkg/*

you destroyed many important files and directories used by the dpkg software.

Unfortunately, there is no easy way to get back a working system without a full restore from backup or re-installation. You may be able to restore the missing files manually, one-by-one, but it is going to be no less than a major headache.

When you asked the same question here you were told (in a comment) to re-install or restore from backup. It is still a good idea, and opening a new question won't help you get a better answer.

Edit: I now realise you asked this question before the other question. But you also asked others. Stop creating new questions asking about this same problem.

You see, often when you hose an application, you can repair it by purging and re-installing the relevant package. In this case, the application you've hosed is the very one you would need in order to install and remove packages.

share|improve this answer
add comment

Create the directory manually with mkdir and do what you already did after that. This should fix it.

share|improve this answer
    
Which directory and how? –  Braiam Sep 11 '13 at 12:19
    
Sudo mkdir /var/lib/dpkg/updates –  Josh Sep 11 '13 at 15:12
    
What? Sudo mkdur /var/lib/dpkg/updates? That's is wrong in so many places. First, Sudo do not exist. Linux is case-sensitive, and binaries are by default lowercase. –  Braiam Sep 11 '13 at 15:20
    
mkdur doesn't exist either –  troylatroy Sep 11 '13 at 17:28
add comment

To start you need to recreate your /var/lib/dpkg/status file. You should probably have a backup at /var/backups/dpkg.status.0

So first we create the dpkg folder and then copy /var/backups/dpkg.status.0 to /var/lib/dpkg/status as follows

 mkdir /var/lib/dpkg
 cp /var/backups/dpkg.status.0 /var/lib/dpkg/
 mv /var/lib/dpkg/dpkg.status.0 /var/lib/dpkg/status

Create a folder called update inside /var/lib/dpkg

 mkdir /var/lib/dkpg/update

Now you Have to reinstall all the installed Applications.

NOTE:

There are extra backups at /var/backups/ namely dpkg.status.1, dpkg.status.2 but are in zipped form. If you want to use it you will have to uncompress it.Better go with the default one as explained above.For extra info see the source below

Source

share|improve this answer
add comment

Open a terminal and type the following:

sudo mkdir -p /var/lib/dpkg/{updates,alternatives,info,parts,triggers}
sudo killall apt* software-center* dpkg
sudo apt-get clean
sudo apt-get update
sudo apt-get purge wine1.4 ia32-libs-multiarch
sudo apt-get upgrade

The first command gets rid of the "cannot scan updates directory" (along with the disaster of the rm -r), then we need to end any dkpg/apt instance to get rid of "Unable to lock" message. Third, lets clean the package cache, update the software list cache and upgrade.

share|improve this answer
    
now I got this: Reading package lists... Done Building dependency tree Reading state information... Done You might want to run 'apt-get -f install' to correct these. The following packages have unmet dependencies: ia32-libs : Depends: ia32-libs-multiarch but it is not installable wine1.4 : Depends: wine1.4-i386 (= 1.4.1-0ubuntu5) but it is not installable E: Unmet dependencies. Try using -f. –  Mj125 Sep 11 '13 at 12:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.