0

I was trying to install matlab couple of days ago but the process stuck due to the malfunction of the ISO file. Now I cannot stop this installation because it prevents me to get update or upgrade.

This is the error I get when I try to install smth from the terminal:

ubuntu@ubuntu-Inspiron-N5010:~$ sudo apt-get upgrade
[sudo] password for ubuntu: 
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?

Thank you in advance

2 Answers 2

1

WARNING: This answer is applicable to Ubuntu version < 11.04, do not use it in a newer version as it will hard freeze your system

You will get this message if you forget to use sudo when executing an apt command.

Otherwise this is a sign that something else is installing or removing software and has locked the apt database while it performs the actions. The programs that can do this are:

  • The Software Center
  • The Update Manager
  • The apt link installer (I think this now goes through SC)
  • The apt-get or aptitude command line utilities.

You can force the lock off by removing the file, but it's not recommended without first closing the program that's holding the lock safely, since you could cause corruption or interrupt an installation (bad).

Try this command in terminal to find what is running

ps -e | grep -e apt -e adept | grep -v grep

Note: If that doesn’t make effect, type the following in terminal that will remove the lock

sudo fuser -cuk /var/lib/dpkg/lock; sudo rm -f /var/lib/dpkg/lock

And the same command can be used for the apt cache lock:

sudo fuser -cuk /var/cache/apt/archives/lock; sudo rm -f /var/cache/apt/archives/lock
1

ther is an procces which has some how stoped or bening penging

type command ps aux | grep apt ant this will show you all running procces which have word apt

now you need to kill that process which is pending and to that type kill process-number jusst replace process-number with actual process number that you wabt to kill.

if this do not work then add sudo in you command like sudo kill process-number or sudo -9 process-number

this much safer way than deleting lock but if this doesn't work then use this method of deleting lock

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .