0

My laptop operates on ubuntu 16.04. when I enter the command on the terminal window to install a new software, it gives the following error:

ashutosh@ashutosh-HP-Pavilion-g4-Notebook-PC:~$ sudo apt-get install arduino
[sudo] password for ashutosh: 
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?

can you please tell me the reason for this..??

0

1 Answer 1

0

Well, it does say what is going on: apt-get can't get a "lock" on the package management files (basically, the guarantee it's the only one who can access it) So, the first idea would be that something else is installing. You get this, for example, if the "Software Updater" is updating your system and at the same you think "gee, I want to install something". The "Software Updater" got the lock, you try to get it and it's obviously refused.

Now, what you want is to figure out which process is actually having the lock. For that we're going to use lsof, which means "list open files". The file of interest is "/var/lib/dpkg/lock".

$ lsof /var/lib/dpkg/lock

Normally this should give you a process that "has" the lock. Close that process and you'll be fine.

If there is no process, it's most likely a stale lock. While I never needed to do it, I'd then remove the lock by issuing:

sudo rm /var/lib/dpkg/lock

Do note you can get the error when you forget "sudo" on package manager commands (apt, apt-get, aptitude, etc...), but yours included it.

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