How to Fix: ‘Could not get lock /var/lib/dpkg/lock-frontend’ in Ubuntu / Linux Mint

Getting error “Could not get lock /var/lib/dpkg/lock-frontend” while installing or removing package in Ubuntu, Debian, Linux Mint, or other apt based systems?

The error indicates another instance of apt process is running. It creates the lock which will be removed when the process completes. While the apt process is running, any other apt-based utility will refuse to run and output the ‘Clould not get lock’ error. The solution is either wait or kill the apt process!

Who create the lock?

Any apt based utility, either command line or graphical tool, will create the lock when it’s running. There are usually:

  • Ubuntu Software.
  • Software Updater (Update Manager).
  • Synaptic Package Manager.
  • apt or apt-get command.
  • Automatic security updates (running in background).

How to Fix the problem?

If any of the previous process is running by you, either wait or close it.

1. Get the process ID:

Don’t know which process created the lock? In recent Ubuntu / Linux Mint releases, it may already tell the ID while you getting the error:

For instance, the picture above outputs the process 61740 held the lock.

If it does not show the process ID, run command sudo lsof /path/to/lock to check out. In the case, the lock file is “/var/lib/dpkg/lock-frontend“. So the command should be:

sudo lsof /var/lib/dpkg/lock-frontend

Ignore the warnings if any, and check the PID of the process:

2. Kill the process via ID:

Finally kill the process by running command in terminal:

sudo kill -9 ID_NUMBER

In the case, the command should be sudo kill -9 61740.

That’s it. Enjoy!

Exit mobile version