This question is an exact duplicate of:

After installing Kali Linux on my VMware machine , I was trying to update the sources.list file , but for some reason while using the command apt-get upgrade It is resulting in error as

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

And the apt-update command is sometimes working, other times it is resulting in Forbidden IP error, could not connect it Linux repository. My Kali repository sources.list file is:

deb http://http.kali.org/kali kali-rolling main non-free contrib

I don't know how to rectify these errors and couldn't find any solution yet.

marked as duplicate by RalfFriedl, G-Man, A.B, Romeo Ninov, countermode Sep 25 '18 at 13:35

This question was marked as an exact duplicate of an existing question.

  • 1
    Are you new to Linux, or just new to Kali Linux? Please read this link and try to determine if Kali Linux is really the right distro for you: unix.stackexchange.com/a/399627/256455 – Tim Kennedy Sep 24 '18 at 13:18
  • 2
    mate I can answer to previous questions - yes kali is not for you - that is for now - to answer and resolve your issue with file itself run command : sudo rm -rf /var/lib/dpkg/lock – Michal Sep 24 '18 at 13:32
  • The first message is easy to be handled:

E:Could not get lock /var/lib/dpkg/lock - open (11: Resources temporarily unavailable)

This message indicates that other program to install/uninstall a software is being open. You should find that software and close it, then reboot the system.

  • The second error message is tricky one:

E:Unable to lock the administration directory (var/lib/dpkg/) is another process using it ?

One of the solutions for this error is to delete the lock, but this is the last resort and not recommended. Alternatives are as follows: 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. Try this command:

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

kill <apt_process_ID>

and if that doesn't work try

kill -9 <apt_process_ID>

This should kill the process and may remove the lock. Killing an apt or aptitude process is harmless unless it is actually in the middle of package installation. In any case, if the process got stuck, you probably don't have a choice but to kill it.

Killing a dpkg process directly, if present, is not a good idea, because if dpkg is active, it is probably manipulating the package database, and killing it may leave the package database in an inconsistent state; i.e. corrupted.

Killing an apt-get or aptitude process is in general much safer.

Now, if the previous steps are failed, then you have to remove the lock (again this is a last resort solution and not recommended).

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

After that, try opening Synaptic package manager again.

  • 1
    I don’t know anything about this particular problem, but if I read your answer in sequence, a reboot happens before all the checking for stuck apt processes... – Jeff Schaller Sep 24 '18 at 16:27
  • Correct @Jeff Schaller . I am not sure about the situation of his system. Maybe he can't reboot! He has opened data, he is part of a network ..... etc. I thought it is good to mention some few things that can be done before rebooting ;). Similar issues are common in Ubuntu too! – user88036 Sep 24 '18 at 16:29
  • 1
    @Goro, maybe OP do not execute the command as root. IMHO this will explain many things... – Romeo Ninov Sep 25 '18 at 6:36
  • @Romeo Ninvo. Many thanks for the note. I completly agree! I am waiting for the OP to communicate, then I will revise the response accordingly. – user88036 Sep 25 '18 at 6:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.