When I ran a command sudo apt-get upgrade (apt upgrade) or sudo apt-get install (apt install ). I receive an error
ubuntu@NUC-DEV:~$ sudo apt-get upgrade E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 6146 (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?
Solution
- Check which process lock file /var/lib/dpkg/lock-frontend by command
sudo lsof /var/lib/dpkg/lock
- Set Process ID (PID) -- Sample is 6750
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME unattende 6750 root 11uW REG 8,2 0 21501278 /var/lib/dpkg/lock
- Kill PID, who hold lock file
sudo kill -9 6750
- Delete and Clear Cache
#Clear Lock File sudo rm /var/lib/dpkg/lock sudo rm /var/lib/dpkg/lock-frontend sudo rm /var/lib/apt/lists/lock #Clear Cache sudo rm /var/cache/apt/archives/lock
- reconfig state
sudo dpkg --configure -a
- Test
sudo apt-get upgrade
again.
Discover more from naiwaen@DebuggingSoft
Subscribe to get the latest posts sent to your email.