解决 unable to lock the administration directory (/var/lib/dpkg/) 问题
阿里开源镜像站提供了raspbian的软件包镜像,国内的用户可以选择改用阿里镜像站作为更新源。
但是在更换源之后,执行 sudo apt-get update && apt-get upgrade -y时报错:
pi@raspberrypi:~$ sudo apt-get update && apt-get upgrade -y
Hit: http://mirrors.aliyun.com/raspbian/raspbian wheezy InRelease
Hit: http://archive.raspberrypi.org/debian stretch InRelease
Reading package lists... Done
E: Could not open lock file /var/lib/dpkg/lock - open (: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
问题原因如下:
锁定的文件会阻止 Linux 系统中某些文件或者数据的访问,这个概念也存在于 Windows 或者其他的操作系统中。
一旦你运行了 apt-get 或者 apt 命令,锁定文件将会创建于 /var/lib/apt/lists/、/var/lib/dpkg/、/var/cache/apt/archives/ 中。
这有助于运行中的 apt-get 或者 apt 进程能够避免被其它需要使用相同文件的用户或者系统进程所打断。当该进程执行完毕后,锁定文件将会删除。
重要提醒:万一你在没有看到 apt-get 或者 apt 进程的情况下在上面两个不同的文件夹中看到了锁定文件,这是因为进程由于某个原因被杀掉了,因此你需要删除锁定文件来避免该错误。
1、首先运行下面的命令来移除 /var/lib/dpkg/ 文件夹下的锁定文件:
$ sudo rm /var/lib/dpkg/lock
2、之后像下面这样强制重新配置软件包:
$ sudo dpkg --configure -a
同时也可以删除 /var/lib/apt/lists/ 以及缓存文件夹下的锁定文件:
$ sudo rm /var/lib/apt/lists/lock
$ sudo rm /var/cache/apt/archives/lock
接下来,更新你的软件包源列表:
sudo apt-get update && apt-get upgrade -y
解决 unable to lock the administration directory (/var/lib/dpkg/) 问题的更多相关文章
- 解决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的时候特别是安装或更新的时候会出现下面的情况: E: Could not get lock /var/lib/dpkg/lock - open (11: Resource t ...
- 解决0% [Waiting for headers] 导致的unable to lock the administration directory (/var/lib/dpkg/) is another process using it
这是我在配置vim的YouCompleteMe时遇到的问题,我需要使用CMake来编译YCM. 在我输入 $ sudo apt install cmake 由于网络原因导致安装一直卡在0% [Wait ...
- 修复 Ubuntu 中“Unable to lock the administration directory (/var/lib/dpkg/)”
在 Ubuntu 或者它的衍生版如 Linux Mint(我已经作为日常工作使用的系统)中使用 apt-get 命令或者其相对更新的APT 管理工具时,你可能会在命令行中看到一个 unable to ...
- E: Unable to lock the administration directory (/var/lib/dpkg/)
如何修复 Ubuntu 中的“Unable to lock the administration directory (/var/lib/dpkg/)” 在 Ubuntu 或者它的衍生版如 Linux ...
- 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?
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)E: Unable to l ...
- Unable to lock the administration directory (/var/lib/dpkg/),is another process using it?
Description:无法获得锁 /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)Unable to lock the ...
- Fix "Unable to lock the administration directory (/var/lib/dpkg/)" in Ubuntu
While using the apt-get command or the relatively new APT package management tool in Ubuntu Linux or ...
- E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
sudo rm /var/lib/dpkg/locksudo dpkg --configure -a
- Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?
I see pretty much all the answers recommend deleting the lock. I don't recommend doing that as a fir ...
随机推荐
- GenerateId类:生成唯一id、订单号
using System;using System.Security.Cryptography; namespace Infrastructure{ public class GenerateId { ...
- [LC] 442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others ...
- 吴裕雄--天生自然Android开发学习:1.2.1 使用Eclipse + ADT + SDK开发Android APP
1.前言 这里我们有两条路可以选,直接使用封装好的用于开发Android的ADT Bundle,或者自己进行配置 因为谷歌已经放弃了ADT的更新,官网上也取消的下载链接,这里提供谷歌放弃更新前最新版本 ...
- JavaScript小数转百分比
在浏览器的控制台操作0.28*100会得到28.000000000000004这样一个不太精确的值 进行转换 toPercent(point){ let str = Number(point * 10 ...
- java生成饼图
pom.xml文件导入依赖包 <!-- https://mvnrepository.com/artifact/org.jfree/jfreechart --> <dependency ...
- Struts2开发基本步骤
1 加载jar文件 commons-fileupload.jar commons-io.jar commons-lang.jar freemaker.jar ognl.jar ...
- Python Web 基础向(四) 浅谈数据层
数据层一般会给人带来一些困扰,在于其定位不准确.聚合Model的工作也可以放在逻辑层做,但会导致逻辑层变重,经常出现大段晦涩代码.因此我的建议是保留Model聚合层,尽管会导致工作量的略微增加,但却可 ...
- 添砖加瓦:几种常见的数据摘要算法(MD5、CRC32、SHA1和SHA256)
1.算法概述 数据摘要算法是密码学算法中非常重要的一个分支,它通过对所有数据提取指纹信息以实现数据签名.数据完整性校验等功能,由于其不可逆性,有时候会被用做敏感信息的加密.数据摘要算法也被称为哈希(H ...
- html解析过程
Web页面运行在各种各样的浏览器当中,浏览器载入.渲染页面的速度直接影响着用户体验 简单地说,页面渲染就是浏览器将html代码根据CSS定义的规则显示在浏览器窗口中的这个过程.先来大致了解一下浏览器都 ...
- 详解服务器性能测试的全生命周期?——从测试、结果分析到优化策略(转载)
服务器性能测试是一项非常重要而且必要的工作,本文是作者Micheal在对服务器进行性能测试的过程中不断摸索出来的一些实用策略,通过定位问题,分析原因以及解决问题,实现对服务器进行更有针对性的优化,提升 ...