Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) 解决办法

1: The problem I encountered:

In turn run apt install vim command when the following error:

2: Reference blog:

In the case of Ubuntu, sometimes using sudo apt-get install to install the software, there will be about a

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?

3: The cause of the problem: mainly because of apt is still running.

4: Solution: Kill all apt processes.

1: Find all related processes apt, and with orders to kill.

Copy the code
root@ubuntu:~# ps afx|grep apt
 3284 pts/0    S+     0:00 \_ grep --color=auto apt
 2869 ?        Ss     0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
 2873 ?        S      0:00  \_ /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install

root@ubuntu:~# sudo kill -9 2873
root@ubuntu:~# sudo kill -9 2869
Copy the code

 2: Remove the lock file

Locked file blocks access to certain files or data Linux system, this concept also exists in Windows or other operating systems.

Once you run the command apt-get or apt, locked files will be created in  /var/lib/apt/lists/, /var/lib/dpkg/, /var/cache/apt/archives/ in.

This helps run the apt-get or apt process can be avoided by other users or system processes need to use the same files interrupted. When this process is finished, the lock file will be deleted.

and so:

  1: Remove the lock files in the corresponding directory:

  2: Force reconfiguration of the package:

  3: Update package source files:

root@ubuntu:~# rm /var/lib/dpkg/lock
root@ubuntu:~# dpkg --configure -a
root@ubuntu:~# apt update

  3: problem solving, execution apt install command is successful.

Guess you like

Origin www.cnblogs.com/fighter007/p/11970732.html