How to fix “could not lock /var/lib/dpkg/lock” error

error

If you have a distro and you have tried to use the package manager and it has jumped you the error "could not lock /var/lib/dpkg/lock", don't worry. It is not something serious that you should worry about, although it is annoying. In addition, it has a solution, as I will show you in this tutorial explained step by step. This way you will get rid of this inconvenience once and for all and your distro will continue to work like the first day. Well, let's see how...

When does the error occur?

The error "Could not lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)” It usually happens when there is an interrupted update of some package and the update packages get corrupted. This keeps the update processes busy in an infinite loop and will always give you this problem unless you fix it.

Solution to the error Failed to lock /var/lib/dpkg/lock

To solve this error, just follow these simple steps:

  1. Enter the terminal and type the following command to kill the update process that has been left pending and is causing the problem (with the -v option for verbose, -k to kill the process, and -i for the program to indicate what processes will kill and ask permission to stop them):

sudo fuser -vki /var/lib/dpkg/lock

  1. The following is to delete the file where the data of the updates that generated the problem are, and it is done with the following command:

sudo rm -f /var/lib/dpkg/lock

  1. Then the update packages that cause the problem with:

sudo dpkg --configure --a

  1. Now the problem will be ready. You will be able to recheck for updates and install the problematic update again, but before you start, you should run the following command to remove and repair broken packages:

sudo apt-get autoremove

I hope it has been helpful for you


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   HENRY MORA said

    great, thank you very much!!!!!