我没有运行任何软件包安装,但当我尝试安装时出现以下错误德布包。我考虑过重启系统,但这可能会损坏数据库。而且以前也发生过这种情况。
sudo dpkg -i slack-desktop-2.1.2-amd64.deb
dpkg: error: dpkg status database is locked by another process
sudo apt-get update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable Release
Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]
Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:7 http://archive.ubuntu.com/ubuntu xenial-security InRelease
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [188 kB]
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [94.2 kB]
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [387 kB]
Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [383 kB]
Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [147 kB]
Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [326 kB]
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [323 kB]
Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [113 kB]
Fetched 2,058 kB in 5s (360 kB/s)
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?
答案1
尝试使用sudo lsof /var/lib/dpkg/lock
来查看哪个进程锁定了更新程序。
您也可以使用ps -ax | grep dpkg
或,ps -ax | grep apt
但是软件中心和自动更新程序可能会阻止该进程,此时您可以使用来终止有问题的进程kill <process id number>
。
如果这些方法不起作用,可以尝试以下方法无法锁定管理目录(/var/lib/dpkg/),是否有另一个进程正在使用它?
答案2
输入以下行来查找进程 ID:
lsof /var/lib/dpkg/lock-frontend
然后使用它显示的 PID 运行此命令:
kill -9 PID