dpkg 错误,无法安装任何内容“资源暂时不可用”,`dpkg --configure -a` 挂起

dpkg 错误,无法安装任何内容“资源暂时不可用”,`dpkg --configure -a` 挂起

每次我尝试

sudo apt-get upgrade

我明白了

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?

跑步时sudo dpkg --configure -a

Setting up linux-image-4.13.0-46-generic (4.13.0-46.51) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-4.13.0-46-generic
vmlinuz(/boot/vmlinuz-4.13.0-46-generic) points to /boot/vmlinuz-4.13.0-46-generic
 (/boot/vmlinuz-4.13.0-46-generic) -- 
doing nothing at /var/lib/dpkg/info/linux-image-4.13.0-46-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.13.0-46-generic
    /boot/vmlinuz-4.13.0-46-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.13.0-46-generic
    /boot/vmlinuz-4.13.0-46-generic

此后升级停滞。

我无法安装任何东西,总有dpkg需要修复的地方。我试过了所有方法,但还是没用。

答案1

尝试使用带有选项的实用程序/var/lib/dpkg/lock文件来终止进程:fuser-k

sudo fuser -uck /var/lib/dpkg/lock

命令执行期间监视器将会闪烁fuser如果fuser没有帮助删除/var/lib/dpkg/lock文件:

sudo rm -rf /var/lib/dpkg/lock

最后这样做:

sudo apt update

相关内容