Categories
Linux Ubuntu

Fix : Could not get lock /var/lib/dpkg/lock-frontend – Ubuntu 20.04

Step 1: Check which process is running the apt command

Use command to check which process is using apt –

ps aux | grep -i apt

Output I get from at my system –

ps aux | grep -i apt
root      4167  0.0  0.0   4624   804 ?        Ss   06:49   0:00 /bin/sh /usr/lib/apt/apt.systemd.daily install
root      4171  0.0  0.0   4624  1764 ?        S    06:49   0:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install
root      4542  0.0  0.0   4624   848 ?        Ss   07:24   0:00 /bin/sh /usr/lib/apt/apt.systemd.daily update
abhay    13251  0.0  0.0  21532  1048 pts/1    R+   07:40   0:00 grep --color=auto -i apt

apt is used by apt.systemd.daily update, wait for some time, once update if completed, then only apt command can be used.

It can also be confirmed by checking “software & update”, you will se daily update is enabled.

Step 2: If you can’t wait, just kill the process. And used apt command.
sudo kill -9 <process id>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.