Learn how to solve the ubuntu 18.04 terminal error: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

How to solve Ubuntu 18.04 CLI error: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

If you are trying to install a new package on your system with the command line and you got the following exception:

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

This exception happens when:

  1. 'Synaptic Package Manager' or 'Software Updater' is open.
  2. Some apt command is running in Terminal.
  3. Some apt process is running in background.

For above wait for the process to complete. If this does not happen run the following command in your terminal:

sudo killall apt apt-get

Now try to run the command that triggers the exception once again and check if it works. If it doesn't work, proceed to run the following command:

sudo rm /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock*

Or delete every file individually:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*

This removes the three possible lock files that generate the issue:

  • /var/lib/apt/lists/lock
  • /var/cache/apt/archives/lock
  • /var/lib/dpkg/lock*

After removing the lock files, you should be able to proceed with the original command that triggered the exception, however it should work now.

Happy coding !


Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Sponsors