Linux E Could not get lock /var/lib/dpkg/lock – open

WE see this error because some other program is trying to update Ubuntu. When a command or application is updating the system or installing a new software, it locks the dpkg file.

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

Linux E Could not get lock varlibdpkglock open

Method1:
The lock is placed when an apt process is running, and is removed when the process completes. If there is a lock with no apparent process running, this may mean the process got stuck for some reason.

ps aux | grep apt

that will catch processes containing the word apt, at least. If you see an apt-get process or an aptitude process that looks stuck, you can try

sudo kill processnumber

and if that doesn’t work try

sudo kill -9 processnumber

Method2: To remove lock files.

We can now safely remove the lock files using the commands below:

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

After that, we have to reconfigure the packages:

sudo dpkg –configure -a