Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a problem every time I run sudo apt-get update. The following is a output from the terminal:

W: Duplicate sources.list entry http://archive.canonical.com/ubuntu/ precise/partner i386 Packages (/var/lib/apt/lists/archive.canonical.com_ubuntu_dists_precise_partner_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

I need help in resolving the duplicate software source problem. Any help will be greatly appreciated :-)

share|improve this question
    
Did you run sudo apt-get update? –  Mitch Aug 27 '12 at 7:31
    
Run sudo fuser -cuk /var/lib/dpkg/lock and sudo rm -f /var/lib/dpkg/lock in terminal. –  Ravi Aug 27 '12 at 7:35
    
Welcome to Ask Ubuntu! Can you include a answer with instructions on how to do that? Leaving a half-answer as a comment can often cause more harm than good. Thanks. –  fossfreedom Aug 27 '12 at 8:49
add comment

1 Answer

The first thing to try is to check your sources.list file at /etc/apt/sources.list. Open your sources.list file with

gksudo gedit /etc/apt/sources.list  

Remove any duplicates of the lines below that you mentioned:

deb http://archive.canonical.com/ubuntu precise partner
deb-src http://archive.canonical.com/ubuntu precise partner

(You may not have the deb-src enabled; that doesn't matter.)

If that is unsuccessful try these two commands below. The first command removes the lock which could be causing the problem, and the second removes your cached lists, but leaves the folder intact. (The lists will be regenerated when you enter sudo apt-get update.)

sudo rm -f /var/lib/dpkg/lock  
sudo rm -rf /var/lib/apt/lists/*

(Make sure you type correctly and remove the right files, or use the -i (interactive) option instead of the -f (force) option with rm)

Finally, to check everything's back to normal, type

sudo apt-get update

NOTE: The lock error also occurs when Synaptic is also running when you try to update and install programs with the command-line, so make sure you are only using one way to update.

share|improve this answer
add comment

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.