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

Asked by Navin Talati

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

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Navin Talati
Solved:
Last query:
Last reply:
Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Navin Talati (n-m-talati) said :
#3

Thanks