"could not lock" OR "unable to lock" comes every time

Asked by Navin Talati on 2021-01-10

In the terminal, when I give any command for some changes like upgrade or so, after some process happenings, at the end it comes as under:

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?

What does this indicate?
How to resolve it?

Please reply and help.
Navin Talati / 10-01-2021

Question information

English Edit question
Ubuntu Edit question
No assignee Edit question
Last query:
Last reply:
Manfred Hampl (m-hampl) said : #1

The Ubuntu package management system prevents concurrent update by package management programs.
Imagine that you open a window and install a package that depends on another package which is already installed, and at the same time you uninstall that second package in another window. What do you expect to be the result?

To prevent such problems, whenever you start a package management program (apt, update-manager, synaptic, ...) that program creates a lock on a file (and releases that lock at a successful end of the program). If during execution of that program another package management program is started, it also tries to lock the file and fails with the error messages that you see.

Apparently you have a process still running that locks the package management lock file. You have to close that program, before you can start the next one.

The command
sudo fuser -v /var/lib/dpkg/lock
will show some details pf the process that blocks the file.

Manfred Hampl (m-hampl) said : #2

An answer to a quite similar question asked by you (related to a different lock file) was given in https://answers.launchpad.net/ubuntu/+question/679410

Can you help with this problem?

Provide an answer of your own, or ask Navin Talati for more information if necessary.

To post a message you must log in.