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 its derivatives such as Linux Mint (which I actually use as my primary operating system for doing daily work), you might have encountered the error – “unable to lock the administration directory (/var/lib/dpkg/) is another process using it” on the command line.
This error can be so annoying especially for new Linux (Ubuntu) users who may not know exactly the cause of the error.
Below is an example, showing the lock file error in Ubuntu 16.04:
The output below is another possible instance of the same error:
How can you solve the above error in case you bump into it in the future? There are several ways of dealing with this error(s), but in this guide, we will go through the two easiest and probably the most effective ways of solving it.
1. Find and Kill all apt-get or apt Processes
Run the command below to generate a list of all processes whose name comprises of the word apt, you will get a list inclusive of all apt or apt-get processes by using ps and grep commands together with a pipeline.
For each apt-get or apt process that you can see in the output of the command above, kill each process using the command below.
The process ID (PID) is found in the first column from the screenshot above.
2. Delete the lock Files
A lock file simply prevents access to another file(s) or some data on your Linux system, this concept is present in Windows and other operating systems as well.
Once you run an apt-get or apt command, a lock file is created under the any of these directories /var/lib/apt/lists/, /var/lib/dpkg/ and /var/cache/apt/archives/.
This helps to avoid the apt-get or apt process that is already running from being interrupted by either a user or other system processes that would need to work with files being used by apt-get or apt. When the process has finished executing, the lock file is then deleted.
Important: In case a lock is still exiting in the two directories above with no noticeable apt-get or apt process running, this may mean the process was held for one reason or the other, therefore you need to delete the lock files in order to clear the error.
First execute the command below to remove the lock file in the /var/lib/dpkg/ directory:
Afterwards force package(s) to reconfigure like so:
Alternatively, delete the lock files in the /var/lib/apt/lists/ and cache directory as below:
Next, update your packages sources list as follows:
In conclusion, we have walked through two important methods to deal with a common problem faced by Ubuntu (and its derivatives) users, while running apt-get or apt as well as aptitude commands.
Do you have any other reliable methods to share meant for deal with this common error? Then get in touch with us via the feedback form below.
In addition, you may as well want to learn how to find and kill running processes and read through a simple guide to kill, pkill and killall commands to terminate a process in Linux.
Fix "Unable to lock the administration directory (/var/lib/dpkg/)" in Ubuntu的更多相关文章
- E: Unable to lock the administration directory (/var/lib/dpkg/)
如何修复 Ubuntu 中的“Unable to lock the administration directory (/var/lib/dpkg/)” 在 Ubuntu 或者它的衍生版如 Linux ...
- 解决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 ...
- 解决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 ...
- 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 ...
- 修复 Ubuntu 中“Unable to lock the administration directory (/var/lib/dpkg/)”
在 Ubuntu 或者它的衍生版如 Linux Mint(我已经作为日常工作使用的系统)中使用 apt-get 命令或者其相对更新的APT 管理工具时,你可能会在命令行中看到一个 unable to ...
- 解决 unable to lock the administration directory (/var/lib/dpkg/) 问题
阿里开源镜像站提供了raspbian的软件包镜像,国内的用户可以选择改用阿里镜像站作为更新源. 但是在更换源之后,执行 sudo apt-get update && apt-get u ...
- 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 ...
- 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 ...
随机推荐
- 2012 noip提高 Vigenère 密码
P1079 Vigenère 密码 题目描述 16 世纪法国外交家 Blaise de VigenèreBlaisedeVigene`re 设计了一种多表密码加密算法―― VigenèreVigene ...
- [JOYOI] 1096 数字组合
题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题.一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了.幸运的是 ...
- memcached内存分配
Memcached默认情况下采用了名为Slab Allocator的机制分配.管理内存,最大单个存储对象大小为1M. page:分配给slab的最小内存空间,默认为1M,可以在启动时通过-l参数修改 ...
- 转:使用 /proc 文件系统来访问 Linux 内核的内容
使用 /proc 文件系统来访问 Linux 内核的内容 https://www.ibm.com/developerworks/cn/linux/l-proc.html /proc 文件系统并不是 G ...
- k fit in Park Model
software: Gnuplot input: area_averaged_axial_mean_velocity_TI_1.txt # One Rotor, front, eldad blade ...
- You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, i
[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal ...
- CSS小知识点一
1. text-indent属性 缩进文本 通过使用 text-indent 属性,所有元素的第一行都可以缩进一个给定的长度,甚至该长度可以是负值.这个属性最常见的用途是将段落的首行缩进,一 ...
- python之图形界面GUI开发 Tkinter 2014-4-7
1.导入Tkinter 可以使用以下三种方法(1)from Tkinter import *#导入Tkinter(2)import TkinterTkinter.methodA使用 Tkinter.m ...
- 大数据学习——服务器定期上传nginx日志到hdfs
需求:按照所学知识完成如下: 服务器定期上传nginx日志到hdfs 提示: Hdfs的创建文件夹命令: Hadoop fs -mkdir /文件夹名称 Hdfs的上传命令: Hadoop fs -p ...
- 省市区名称code
https://blog.csdn.net/hichinamobile/article/details/51725090 --省 create table t_base_provinces( id ) ...