Kali Linux

How To Fix E: Could not get lock /var/lib/dpkg/lock In kali Linux

E: Could not get lock /var/lib/dpkg/lock
Written by Mubassir patel

I just reinstalled Kali Linux on my PC and after my first login, I tried to run and  apt-get update had the E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)error coming up. Interesting, because I am the only user (I just installed the system) and there’s no other process using dpkg. This was pretty annoying as it stops you from installing updates or new software. Here’s a rundown of the issues:

“E: Could not get lock /var/lib/dpkg/lock” error

This happens when I tried to use apt-get update

root@kali:~# apt-get update
Hit http://http.kali.org sana InRelease       
Hit http://security.kali.org sana/updates InRelease
.
.
Hit http://security.kali.org sana/updates/non-free amd64 Packages              
Fetched 9,334 kB in 2min 18s (67.5 kB/s)                                       
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?

Fixing E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable) error in Kali Linux

Trying to fix the “E: Could not get lock /var/lib/dpkg/lock”

Tried multiple steps

Try 1 – Rebooting:

At this point, I tried the restart and see if that makes any differences. It didn’t.

Try 2: – try with sudo

root@kali:~# sudo apt-get update
Hit http://http.kali.org sana InRelease                                   
.
.
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?

sudo didn’t fix it.

Read This : Telegram Shadow : Telegram Spy Tool

Try 3 – Try Googling

Like some search results returned, I tried to delete the lock file

root@kali:~# rm /var/cache/apt/archives/lock

Then update

root@kali:~# apt-get update
.
.
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?

Nope, still no luck.

Try 4 – Actually, read the error!

Then I actually read the freaking error which I didn’t do till now. Duh, the error is:

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?

Which indicates that the lock file is in the folder /var/lib/dpkg/lock. Silly me! So let’s have a look at the folder/var/lib/dpkg/ to confirm if there is really a lock file in there?

root@kali:~# rm /var/lib/dpkg/
alternatives/   diversions-old  parts/          status-old
available       info/           statoverride    triggers/
diversions      lock            status          updates/

There is a lock file. So let’s delete that.

root@kali:~# rm /var/lib/dpkg/lock

and then try to update again

root@kali:~# apt-get update
Hit http://security.kali.org sana/updates InRelease
.
.
Reading package lists... Done                                                  
root@kali:~#

Booyaa. Worked just fine. Well, ofc it does, when you can write and read properly!!!!

Now just to be on safe side, let’s do an apt-get upgrade

root@kali:~# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  armitage gr-osmosdr iceweasel john john-data libgnuradio-osmosdr0.1.3
  libgnutls-deb0-28 libgnutls-openssl27 libsnmp-base libsnmp-perl libsnmp30
  openvas python-hpack python-impacket python-pyperclip snmp snmpd
17 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/70.6 MB of archives.
After this operation, 12.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Reading changelogs... Done
Preconfiguring packages ...
(Reading database ... 323261 files and directories currently installed.).
.
.
root@kali:~#

Yeah .. working well. and finally, finish it with installing. gimp

root@kali:~# apt-get install gimp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gimp-data libamd2.3.1 libbabl-0.1-0 libcamd2.3.1 libccolamd2.8.0
  libcholmod2.1.2 libcolamd2.8.0 libgegl-0.2-0 libgimp2.0 libopenraw1
  libumfpack5.6.2
Suggested packages:
  gimp-help-en gimp-help gimp-data-extras
The following NEW packages will be installed:
  gimp gimp-data libamd2.3.1 libbabl-0.1-0 libcamd2.3.1 libccolamd2.8.0
  libcholmod2.1.2 libcolamd2.8.0 libgegl-0.2-0 libgimp2.0 libopenraw1
  libumfpack5.6.2
0 upgraded, 12 newly installed, 0 to remove and 0 not upgraded.
Need to get 15.7 MB of archives.
After this operation, 70.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://http.kali.org/kali/ sana/main libamd2.3.1 amd64 1:4.2.1-3 [26.3 kB]
.
.
Fetched 15.7 MB in 2min 37s (99.8 kB/s)                                                                                                                                                                           
Selecting previously unselected package libamd2.3.1:amd64.
(Reading database ... 323276 files and directories currently installed.)
.
.
Processing triggers for libc-bin (2.19-18) ...
Processing triggers for menu (2.1.47) ...
root@kali:~#

Perfect.

Video:

[amazon_link asins=’B077L7SNG8,B074VFZ2GW,B077C37Y1N,B074P26NVR,B079D6KHMC’ template=’ProductCarousel’ store=’mubassir-20′ marketplace=’US’ link_id=’a0a1e044-2853-11e8-bc07-5f8473045dc4′]

About the author

Mubassir patel

Mubassir is a founder and developer of this site. He is a computer science engineer. He has a very deep interest in ethical hacking, penetration testing, website development and including all technology topic.

Leave a Comment