在運(yùn)行apt-get update時(shí)出現(xiàn)這個(gè)問(wèn)題
2:參考博客:
在Ubuntu中,有時(shí)候運(yùn)用sudo apt-get install 安裝軟件時(shí),會(huì)出現(xiàn)一下的情況
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?
3:?jiǎn)栴}原因:主要是因?yàn)閍pt還在運(yùn)行。
4:解決方案:殺死所有的apt進(jìn)程。
1:查找所有apt相關(guān)的進(jìn)程,并用命令殺死。
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:刪除鎖定文件
鎖定的文件會(huì)阻止 Linux 系統(tǒng)中某些文件或者數(shù)據(jù)的訪問(wèn),這個(gè)概念也存在于 Windows 或者其他的操作系統(tǒng)中。
一旦你運(yùn)行了 apt-get 或者 apt 命令,鎖定文件將會(huì)創(chuàng)建于 /var/lib/apt/lists/、/var/lib/dpkg/、/var/cache/apt/archives/ 中。
這有助于運(yùn)行中的 apt-get 或者 apt 進(jìn)程能夠避免被其它需要使用相同文件的用戶或者系統(tǒng)進(jìn)程所打斷。當(dāng)該進(jìn)程執(zhí)行完畢后,鎖定文件將會(huì)刪除。
所以:
1:移除對(duì)應(yīng)目錄下的鎖文件:
2:強(qiáng)制重新配置軟件包:
3:更新軟件包源文件:
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