When ever i install a new application using terminal command, i get this error

E: Could not open lock file /var/lib/dpkg/lock - open (21: Is a directory)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

What I tried is

sudo apt-get update
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo apt-get dist-upgrade

But I cannot solve this. I made a refer to the other answers but it's not finding to workout. Can anyone help? Thanks in advance

share|improve this question
    
have you tried reboot or logout will also do – Prashant Chikhalkar Aug 9 '15 at 8:26
    
Yes! I am struggling with this for long time! I have tried rebooting and logout – hemnath mouli Aug 9 '15 at 8:27
up vote 1 down vote accepted

Try this command in terminal to find what is running

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

If that doesn’t print anything, type the following in terminal to remove the lock

sudo rm -rf /var/lib/dpkg/lock    
sudo rm -rf /var/cache/apt/archives/lock

Also

If you try

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

sudo  kill processnumber

and if that doesn't work try

sudo kill -9 processnumber

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.

share|improve this answer
    
ps -e | grep -e apt -e adept | grep -v grep says 2676 ? 00:00:00 update-apt-xapi and sudo kill -9 processnumber says kill: failed to parse argument: 'processnumber – hemnath mouli Aug 9 '15 at 8:37
2  
Then let that process finish, or if you don't want to wait kill it as said in answer, close synaptic, update manager and other system tools who use lock – Prashant Chikhalkar Aug 9 '15 at 8:38
    
I have only one user. How can i kill it? – hemnath mouli Aug 9 '15 at 8:39
    
read the answer buddy "sudo kill -9 <process id>" for your case "sudo kill -9 2676" ... I think the answer is easy if you know about process ID's (The number given to each running process) .. If it doesn't solve your issue update it accordingly – Prashant Chikhalkar Aug 9 '15 at 8:40
1  
Let us continue this discussion in chat. – Prashant Chikhalkar Aug 9 '15 at 8:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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