How to fix error “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?” The problem arises when a specific process locks the dpkg resource.
To solve it, search for process that’s holding up the resource and kill it. To search the process, run:
$ ps -A | grep apt-get
$ sudo lsof /var.lib/dpkg/lock
The above command will display the process. You can easily see the one which has locked the resource. Note the process id (PID) and kill it using the kill command.
$ sudo kill PID
Each Linux or Unix process or a running program is automatically assigned a unique process identification number (PID). A PID is automatically assigned number to each process on the system.
Kill command can be used to kill or terminate a process using “Signal” or “PID.” The command kill sends the specified signal to the specified processes or process groups. If no signal is specified, the TERM signal is sent. This TERM signal will kill processes that do not catch it; for other processes it may be necessary to use the KILL signal (number 9), since this signal cannot be caught.
Once the process is killed, you may have to manually run ‘sudo dpkg –configure -a’ to correct the problem “dpkg was interrupted”. Run the command:
$ sudo dpkg –configure -a
$ apt-get update
That’s all. The problem must be resolved by now. If the error persists, run the following commands in terminal,
$ sudo su
$ sudo rm /var/lib/apt/lists/lock
$ apt-get update
Alternate Method – There is also another method to solve the problem:
$ sudo rm /var/lib/dpkg/lock
$ sudo apt-get update