在Ubuntu中,有时候运用sudo apt-get install 安装软件时,会出现一下的情况
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?
主要原因:主要是因为apt还在运行
解决方案:杀死所有的apt进程
1:查找所有apt相关的进程,并用命令杀死。
hlp@hlp-Lenovo-G405:~$ ps afx|grep apt
3284 pts/0 S+ 0:00 \_ grep --color=auto apt
2869 ? Ss 0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
2873 ? S 0:00 \_ /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install
hlp@hlp-Lenovo-G405:~$ sudo kill -9 2873
hlp@hlp-Lenovo-G405:~$ sudo kill -9 2869
2:删除锁定文件
hlp@hlp-Lenovo-G405:~$ sudo rm /var/lib/dpkg/lock
hlp@hlp-Lenovo-G405:~$ sudo dpkg --configure -a
hlp@hlp-Lenovo-G405:~$ sudo apt update