I cannot install new packages: "Could not get lock /var/lib/dpkg/lock"

I tried to install jdk/jre:

[email protected]:~$ sudo apt-get install openjdk-7-jre-headless

However, I got this message:

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?

I cannot get git to install either, so I don’t think it is a problem with the specific package I selected. What that error means, and how to deal with it?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Do you have the GUI package manager/or update manager programs running? If so there’s a conflict, simply close those programs down and your command line should work.

Solution 2

This should be used as last resource. If you use this carelessly you can end with a broken system. Please evaluate other answers first before trying this.
You can delete the lock file with the following command:

sudo rm /var/lib/dpkg/lock

After that, try installing again.

Solution 3

This is what worked for me:

1) Open a terminal

2) sudo dpkg –configure -a

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply