关于Ubuntu中E: Could not get lock /var/lib/dpkg/lock - open的三种解决方案

问题

Ubuntu中,有时候运用sudo  apt-get install 安装软件时,会出现如下的情况:

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?

三种解决方案

这是由于apt因某种原因还在后台运行

1、找到并且杀掉所有的apt-get 和apt进程

运行下面的命令来生成所有含有 apt 的进程列表,你可以使用ps和grep命令并用管道组合来得到含有apt或者apt-get的进程。

ps -A | grep apt

kill所有的 apt 以及 apt-get 进程

$ sudo kill -9 processnumber
或者
$ sudo kill -SIGKILL processnumber

2、删除锁定文件

一旦你运行了 apt-get 或者 apt 命令,锁定文件将会创建于 /var/lib/apt/lists//var/lib/dpkg//var/cache/apt/archives/ 中。锁定的文件会阻止 Linux 系统中某些文件或者数据的访问, 这有助于运行中的 apt-get 或者 apt 进程能够避免被其它需要使用相同文件的用户或者系统进程所打断。当该进程执行完毕后,锁定文件才会删除。

刚装好的Ubantu系统,内部缺少很多软件源,这时,系统会自动启动软件源更新进程“apt-get”,并且它会一直存活。由于它在运行时,会占用软件源更新时的系统锁(以下称“系统更新锁”,此锁文件在“/var/lib/apt/lists/”目录下)。而当有新的apt-get进程生成时,就会因为得不到系统更新锁而出现"E: 无法获得锁 /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)"错误提示!

上次apt安装没有正常完成也会出现这种情况。

首先移除 /var/lib/dpkg/ 文件夹下的锁定文件:

$ sudo rm /var/lib/dpkg/lock

之后像下面这样强制重新配置软件包:

$ sudo dpkg --configure -a

3、删除锁定文件

$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/cache/apt/archives/lock

以上三种方法任选其一即可。

参考链接:

1、https://blog.csdn.net/u011596455/article/details/60322568

2、https://blog.csdn.net/zyxlinux888/article/details/6358615

原文地址:https://www.cnblogs.com/lfri/p/10421281.html

时间: 2024-10-27 00:59:23

关于Ubuntu中E: Could not get lock /var/lib/dpkg/lock - open的三种解决方案的相关文章

Ubuntu中针对问题 E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)的解决方案

一.问题描述: 在ubuntu中有时因为错误的操作,而导致在执行 sudo apt-get install xxxx出现如下错误: 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?

Ubuntu中出现“Could not get lock /var/lib/dpkg/lock”的解决方法

在运行Ubuntu安装软件,使用命令sudo  apt-get install时,有时会出现以下的错误: 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? 这个错误一般情况下是因为apt还在

关于Ubuntu中Could not get lock /var/lib/dpkg/lock解决方案

如果运行sudo apt-get install*****,出现: 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? 就是因为apt还在运行,那就结束apt进程运行,有两种方法: 一: 查看

【ubuntu 】常见错误--Could not get lock /var/lib/dpkg/lock

ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock 通过终端安装程序sudo apt-get install xxx时出错: 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

ubuntu更新出错--Could not get lock /var/lib/dpkg/lock

ubuntu在vps上安装好后,通常第一个命令是更新系统软件.然而在运行的过程中,却出现这样的错误: 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? 出现这个问题可能是有另外一个程序正在运

ubuntu 常见错误--Could not get lock /var/lib/dpkg/lock

通过终端安装程序sudo apt-get install xxx时出错: 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? 出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用.而

(八)ubuntu安装软件提示:Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

question: [email protected]:/usr/src/Linux-headers-3.5.0-23-generic$ sudo apt-get install cheese [sudo] password for ubuntu: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)E: Unable to lock the administration di

ubuntu下安装软件Could not get lock /var/lib/dpkg/lock错误

今天在ubuntu安装ssh的时候报了下面的错误: 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? 查了一下,出现此错误的原因一是有别的资源在安装,二是上一次安装没有正常退出导致锁没有释

ubuntu常见错误--Could not get lock /var/lib/dpkg/lock解决

通过终端安装程序sudo apt-get install xxx时出错:(或者卸载的时候) 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? 出现这个问题可能是有另外一个程序正在运行,导致资