7
advait@advait-Bravo-15-A4DDR:~$ sudo apt install ubuntu-restricted-extras
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)      
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)      
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)      
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)      
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)      
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)  
Advait
  • 505
  • 2
  • 7
  • 14
  • 3
    Another process synaptic is holding ownership of the lock file. Close the synaptic or kill it sudo killall -9 synaptic then re-run Your apt command. If that won't work and synaptic is already killed just remove the lock file sudo rm /var/lib/dpkg/lock-frontend and re-run apt. – Michal Przybylowicz Jul 17 '21 at 11:41
  • 1
    Check another workspace, or another window, you'll have started synaptic and caused the hold, and then forgotten about it. – guiverc Jul 17 '21 at 11:42

3 Answers3

8

You can force close the process by using the process id.

If your terminal says,

Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 43843 (synaptic)

Then, the process id in your case is 43843.

To kill the process use this command,

sudo kill 43843
ibnɘꟻ
  • 183
  • 1
  • 4
7

Close synaptic package manager, and the "sudo apt install" command will automatically continue.

You cannot have two different applications that work with the APT package management system open at the same time.

Yes, I very frequently see the same messages as you ;)

vanadium
  • 88,010
0

This answer on Unix & Linux SE by Stéphane Chazelas has some useful commands:

If you want to kill processes based on their name or argument list, use pkill.

pkill regexp

Will kill all processes whose name matches the regexp extended regular expression.

pkill -f regexp

Will kill all processes whose list of arguments (including the first which usually contains the command name) concatenated with spaces matches the regexp.

Zanna
  • 70,465
  • Thanks for the suggestion but unfortunately I have no idea what "regexp" or a regular expression is. I'll have to research. – Advait Jan 13 '22 at 15:41