Run the command below to generate a list of all processes whose name comprises of the word apt, you will get a list inclusive of all apt or apt-get processes by using ps and grep commands together with a pipeline.
ps -A | grep apt
For each apt-get or apt process that you can see in the output of the command above, kill each process using the command below.
The process ID (PID) is found in the first column from the screenshot above.
sudo kill -9 processnumber
sudo kill -SIGKILL processnumber
For instance, in the command below where 9 is the signal number for the SIGKILL signal, will kill the first apt process:
sudo kill -9 13431
sudo kill -SIGKILL 13431
First execute the command below to remove the lock file in the
sudo rm /var/lib/dpkg/lock
Afterwards force package(s) to reconfigure like so:
sudo dpkg --configure -a
Alternatively, delete the lock files in the
/var/lib/apt/lists/ and cache directory as below:
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
Next, update your packages sources list as follows:
sudo apt update
sudo apt-get update
Full info https://www.tecmint.com/fix-unable-to-lock-the-administration-directory-var-lib-dpkg-lock/