dpkg: error: dpkg frontend is locked by another process

本文将解决 dpkg: error: dpkg frontend is locked by another process 错误。

今日在 Ubuntu20 上,使用 dpkg 安装 vim 编辑器时抛出 “dpkg: error: dpkg frontend lock is locked by another process”错误。如下:

snow@ubuntu:~$ sudo dpkg -P vim
dpkg: error: dpkg frontend lock is locked by another process

上面错误信息大概意思是“dpkg 命令被其他进程锁定了”。

此时,我们可以使用“sudo apt-get install -f”命令查看具体是哪个文件将 dpkg 命令锁定了。如下:

snow@ubuntu:~$ sudo apt-get install -f
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 232324 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

根据提示信息可知 dpkg 被“/var/lib/dpkg/lock-frontend”文件锁定,那么我们就删除该文件。如下:

snow@ubuntu:~$ sudo rm /var/lib/dpkg/lock-frontend

成功删除“/var/lib/dpkg/lock-frontend”文件后,使用 apt-get install 试试能够使用了。如下:

snow@ubuntu:~$ sudo apt-get install tree
E: Could not get lock /var/lib/dpkg/lock. It is held by process 232324 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

apt-get 抛出了“/var/lib/dpkg/lock”锁定文件,删除该文件再试。如下:

snow@ubuntu:~$ sudo rm /var/lib/dpkg/lock

再次,试试安装 tree。如下:

snow@ubuntu:~$ sudo apt-get install tree
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  tree
1 upgraded, 0 newly installed, 0 to remove and 198 not upgraded.
Need to get 43.0 kB of archives.
After this operation, 6,144 B of additional disk space will be used.
Get:1 https://us.archive.ubuntu.com/ubuntu focal/universe amd64 tree amd64 1.8.0-1 [43.0 kB]
Fetched 43.0 kB in 37s (1,153 B/s)
(Reading database ... 189840 files and directories currently installed.)
Preparing to unpack .../tree_1.8.0-1_amd64.deb ...
Unpacking tree (1.8.0-1) over (1.6.0-1) ...
Setting up tree (1.8.0-1) ...
Processing triggers for man-db (2.9.1-1) ...

问题解决了,仅供参考!

所谓天才,只不过是把别人喝咖啡的功夫都用在工作上了。——鲁迅
0 不喜欢
说说我的看法 -
全部评论(
没有评论
关于
本网站专注于 Java、数据库(MySQL、Oracle)、Linux、软件架构及大数据等多领域技术知识分享。涵盖丰富的原创与精选技术文章,助力技术传播与交流。无论是技术新手渴望入门,还是资深开发者寻求进阶,这里都能为您提供深度见解与实用经验,让复杂编码变得轻松易懂,携手共赴技术提升新高度。如有侵权,请来信告知:hxstrive@outlook.com
公众号