博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
修复 Ubuntu 中“Could not get lock /var/lib/dpkg/lock”
阅读量:4229 次
发布时间:2019-05-26

本文共 842 字,大约阅读时间需要 2 分钟。

前情提要

  • 操作系统:Ubuntu18.04
  • 问题描述:在使用apt-get配置应用的时候提示以下错误
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-get 或者 apt 进程

ps aus | grep apt

方案二

如果方案一不奏效,那就试试方案二。

我们都知道,操作系统中一个进程为了避免在运行中,由于其所需的文件被其他需要该文件的进程打断,通常会将该文件进行锁定,阻止系统其他进程对这些文件或者数据的访问。

运行 apt-get 或者 apt 命令的时候,锁定文件将会创建于 /var/lib/apt/lists/、/var/lib/dpkg/、/var/cache/apt/archives/ 中。当apt-get或者apt进程由于某个原因被杀掉了,没有主动删除该锁定文件,就会出现这个问题,所以需要我们手动来删除这些锁定文件。

sudo rm /var/lib/dpkg/locksudo rm /var/lib/apt/lists/locksudo rm /var/cache/apt/archives/locksudo dpkg --configure -a #重新配置软件包sudo apt update #更新软件列表

方案三(重要!!!!)

对于桌面版的ubuntu,可以试试如下的命令,取消后台更新服务:

systemctl stop apt-daily.timersystemctl stop apt-daily.service

不行再杀apt进程:)

转载地址:http://bgiqi.baihongyu.com/

你可能感兴趣的文章
Python in a Nutshell
查看>>
Microsoft Visual C++ .NET Professional Projects
查看>>
Excel 2007 Advanced Report Development
查看>>
Security Metrics: Replacing Fear, Uncertainty, and Doubt
查看>>
Accelerating Process Improvement Using Agile Techniques
查看>>
The New Language of Business: SOA & Web 2.0
查看>>
Programming Mobile Devices: An Introduction for Practitioners
查看>>
Designing for Networked Communications: Strategies and Development
查看>>
Building a Monitoring Infrastructure with Nagios
查看>>
Illustrated C# 2005
查看>>
Pro ASP.NET 2.0 E-Commerce in C# 2005
查看>>
Thinking Animation: Bridging the Gap Between 2D and CG
查看>>
Ajax in Practice
查看>>
Flash Animation for Teens
查看>>
The Oracle Hacker's Handbook: Hacking and Defending Oracle
查看>>
Microsoft Windows PowerShell: TFM
查看>>
Java Drawing with Apache Batik: A Tutorial
查看>>
Essential Windows Presentation Foundation
查看>>
Model-Driven Design Using Business Patterns
查看>>
Core Internet Application Development with ASP.NET 2.0
查看>>