~ $ sudo apt-get update
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
Absolute Solution:
This should be used as last resort. If you use this carelessly you can end up with a broken system. Please try the other solutions before doing this.
You can delete the lock file with the following command:
sudo rm /var/lib/apt/lists/lock
You may also need to delete the lock file in the cache directory
sudo rm /var/cache/apt/archives/lock
Possible reason for this error:
Probably you run 2 instances of program or you have synaptic or some another package manager.
You may either have synaptic open, or have another terminal window open running apt-get, or have the update manager running.Check it and see if any of those are running,if any of them is running close it and try again. Only one program can hold the lock. Make sure that you are not running aptitude, synaptic or adept. Close the program and run it again it should work.
Alternative & safest solutions:
Solution 01: Wait for few minutes because apt-get update may have been running in background. This happens when you have just started the Linus Mint/Ubuntu. Try to run apt-get update few minutes later, DO NOT DELETE ANYTHING FIRST.
Solution 02:
search for processes.
ps -A | grep apt-get
then see if there any process running as apt-get
kill that process it by using:
sudo kill -9
for example if process id is 7356
sudo kill -9 7356
then run the sudo apt-get update
Note: If you are sure that you have no instances of dpkg or apt running and you still get the message, you can just delete the file:
sudo rm /var/lib/apt/lists/lock
A lock file is just a file with zero size that indicates locking of a resource.
You may also need to delete the lock file in the cache directory
sudo rm /var/cache/apt/archives/lock
Solution 03:
Only one program can hold the lock. Make sure that you are not running aptitude, synaptic or adept. Close the program and run it again it should work.You may either have synaptic open, or have another terminal window open running apt-get, or have the update manager running.Check it and see if any of those are running,if any of them is running close it and try again.
Try this command in terminal to find what is running
ps -e | grep -e apt -e adept | grep -v grep
Note: If that doesn’t print anything, type the following in terminal to remove the lock
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
Now you can install any Packages.
Sources:
http://askubuntu.com/questions/15433/unable-to-lock-the-administration-directory-var-lib-dpkg-is-another-process
http://askubuntu.com/questions/346143/e-could-not-get-lock-var-lib-dpkg-lock-open-11-resource-temporarily-unavai
http://askubuntu.com/questions/452638/how-can-i-solve-unable-to-lock-the-administration-directory-var-lib-dpkg