Ubuntu升级报错:Could not get lock

2021年8月28日 | 分类: 【技术】

当Ubuntu升级时报错:

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

方法:

sudo killall apt apt-get

如果提示没有apt进程:

apt: no process found
apt-get: no process found

依次执行:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
sudo dpkg --configure -a
sudo apt update

参考:https://askubuntu.com/questions/1249790/e-could-not-get-lock-var-lib-dpkg-lock-frontend-it-is-held-by-process-5200-a

如果意外中断,可能报错:

dpkg: error: parsing file '/var/lib/dpkg/updates/0133' near line 0:
 newline in field name '#padding'

执行:

sudo rm /var/lib/dpkg/updates/*

参考:https://blog.csdn.net/czw0723/article/details/82750330