[Ubuntu] 無法更新系統Could not get lock

問題:

無法upgrade

$ sudo apt-get update

Hit:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease  

Hit:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease

Hit:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease

Hit:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease

Reading package lists... Done

$ sudo apt-get -y dist-upgrade

E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 3481 (unattended-upgr)

N: Be aware that removing the lock file is not a solution and may break your system.

E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

解決方法:

$ sudo rm /var/lib/dpkg/lock-frontend

Example: