0

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 :-)

Ravi
  • 1,384

1 Answers1

1

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.