This error comes if another program is making some operations on packages (e.g. you're running an update, you have Synaptic opened, etc. ). Only one program at a time is allowed to do so.
The way the package manager ensures this, is to check if a file
/var/lib/dpkg/lock exists when it starts operating. If it doesn't exist, then the program creates one. It then removes it when it finishes its operation. So if the file exists, it means that another package operation is running, or that an operation didn't finish correctly and thus didn't delete the file.
Check that the program you're using (no matter if this is Synaptic, Ubuntu Software Center or command line
apt-get) is the only one open at the moment.
Try also to wait some time: Ubuntu checks periodically for updates, and if you're trying to install VLC while this is happening you might get the error. It should take maximum a few minutes (less than one with a good connection), so if after a short time you still get this error, this is not the problem.
If you have checked all the previous and you're still having the issue, there's two possibilities:
- there is still a
dpkg process running in the background: you can easily check by opening System Monitor, looking at processes running and search for
dpkg. Or, in a terminal, run
ps aux | grep dpkg | grep -v grep: if you get nothing, you're sure this is not the case. If, instead, you find a
dpkg process, then something is running. Try waiting. In any case, after restarting your machine the problem should not appear any longer.
- At some point, a package operation (installation, update, removal, or any other) crashed/failed/was incorrectly interrupted. This means that it was unable to delete the file
/var/lib/dpkg/lock, as explained. In this case, you can safely remove such file. From a terminal, run
sudo rm /var/lib/dpkg/lock.
After this, you should be able to install any software again