Search This Blog

Sunday, March 4, 2018

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

I just reinstalled Kali Linux in my PC and after my first logon, 



I tried to run apt-get update

and had 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 softwares. Here’s a run down 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 - blackMORE Ops

Trying to fix the error

Tried multiple steps

Try 1 – Rebooting:

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

Try 2: – try with sudo

I tried using sudo to see if this was related with this other error dpkg: warning: ‘ldconfig’ not found in PATH or not executable.
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.

Try 3 – Try Googling

Like some search results returned, I tried to delete 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 /var/lib/dpkg/lock folder. Silly me! So let’s have a look into /var/lib/dpkg/ folder to confirm is 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

If the lock does not remove first time repeat the process above. The screen shot below shows the process of removing the lock as you can see the lock did not remove the first time and I had to repeat the process.

and Use dpkg –configure -a to force packages to reconfigure.

#rm /var/lib/dpkg/lock
#sudo dpkg --configure -a

if like this error other lock file also create error go to that path and then delete that lock file like this error

You can delete the lock file with the following command:
sudo rm /var/lib/apt/lists/lock


You may also need to delete the lock file in the cache directory
sudo rm /var/cache/apt/archives/lock 
sudo rm /var/lib/dpkg/lock

---------------------------------------------------Done---------------------------------------------------
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.

Moral of this post

Sometimes it really helps when you actually read the error and not just follow Google search results blindly

Add To Google BookmarksStumble ThisFav This With TechnoratiAdd To Del.icio.usDigg ThisAdd To RedditTwit ThisAdd To FacebookAdd To Yahoo

0 comments:

Post a Comment