系统升级到18.04后执行apt-get install的时候报错
root@zhf-maple:/home/zhf/桌面# apt-get install vim-scipts
E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
E: 无法获取 dpkg 前端锁 (/var/lib/dpkg/lock-frontend),是否有其他进程正占用它?
这是因为升级后某些软件包还在占用apt资源,通过ps -aux | grep apt 查看哪些在占用apt进程,下面红色标红的这些都是在占用apt的进程
root 5394 0.0 0.0 4628 772 ? Ss 14:36 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
root 5405 0.0 0.0 4628 1660 ? S 14:36 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install
root 11471 0.0 0.0 55624 7128 pts/1 S+ 14:39 0:00 /usr/lib/apt/apt-helper download-file http://archive.canonical.com/pool/partner/a/adobe-flashplugin/adobe-flashplugin_20190409.1.orig.tar.gz /var/lib/update-notifier/package-data-downloads/partial/adobe-flashplugin_20190409.1.orig.tar.gz SHA256:b3ceaad9bfe610f0c6ea847b80a6cd3b6e5071c41efccc8974ea58d0e040fc9c
_apt 11473 0.2 0.1 83828 9100 pts/1 S+ 14:39 0:01 /usr/lib/apt/methods/http
root 11564 0.0 0.0 55592 7184 ? S 14:39 0:00 /usr/lib/apt/apt-helper download-file http://archive.canonical.com/pool/partner/a/adobe-flashplugin/adobe-flashplugin_20190409.1.orig.tar.gz /var/lib/update-notifier/package-data-downloads/partial/adobe-flashplugin_20190409.1.orig.tar.gz SHA256:b3ceaad9bfe610f0c6ea847b80a6cd3b6e5071c41efccc8974ea58d0e040fc9c
_apt 11566 0.1 0.1 83828 9096 ? S 14:39 0:01 /usr/lib/apt/methods/http
root 12482 0.0 0.0 16180 1064 pts/2 S+ 14:52 0:00 grep --color=auto apt
执行kill命令杀掉这些进程
kill -9 5394
kill -9 5405
kill -9 11471
kill -9 11564
kill -9 11566
然后执行:
rm /var/cache/apt/archives/lock
rm /var/lib/dpkg/lock
这样就能顺利执行apt-get install的命令了
来源:oschina
链接:https://my.oschina.net/u/4362820/blog/3575076