Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running 12.04 64bit, and every time I update using the command land, I always get

W: Duplicate sources.list entry http://gb.archive.ubuntu.com/ubuntu/ precise/restricted amd64 Packages (/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_precise_restricted_binary-amd64_Packages)
W: Duplicate sources.list entry http://gb.archive.ubuntu.com/ubuntu/ precise/restricted i386 Packages (/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_precise_restricted_binary-i386_Packages)
W: Duplicate sources.list entry http://gb.archive.ubuntu.com/ubuntu/ precise-updates/restricted amd64 Packages (/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_precise-updates_restricted_binary-amd64_Packages)
W: Duplicate sources.list entry http://gb.archive.ubuntu.com/ubuntu/ precise-updates/restricted i386 Packages (/var/lib/apt/lists/gb.archive.ubuntu.com_ubuntu_dists_precise-updates_restricted_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems

I've looked at loads of suggestions from previous problems including unselecting the sources from software sources, or manually removing the 'duplicates' manually from sources.list.

However, when trying to fix it, I've not found the duplicates highlighted anywhere? So I have no idea why this message keeps coming up.

The errors aren't causing anything detrimental to my system but it just looks a bit messy and I would like to know what's causing it.

Any ideas?

Thanks!

share|improve this question
Could you paste the contents of your sources.list? – jackweirdy Jun 26 '12 at 12:33
Please share the output of the following files and/or commands with us (instructions in this answer): file /etc/apt/sources.list, command apt-config dump – izx Jun 26 '12 at 12:35
List the content of /etc/apt/sources.list.d – konrad Jun 26 '12 at 12:47
sources.list: paste.ubuntu.com/1060944 apt-config dump: paste.ubuntu.com/1060951 sources.list.d: paste.ubuntu.com/1060947 Cheers! – jfy133 Jun 26 '12 at 15:42

3 Answers

up vote 4 down vote accepted

Make a back up copy of your sources.list:

sudo cp /etc/apt/sources.list{,.backup}

Now remove the original and update:

sudo rm /etc/apt/sources.list && sudo apt-get update
share|improve this answer
How can he update without sources.list file? – Anwar Jul 4 '12 at 5:27
It will repopulate. =) – wojox Jul 4 '12 at 5:28
@wojox It works, thanks. – quantme Dec 16 '12 at 5:26

Your sources.list really has duplicate entries.

First Let's see the correct form of a repository line or source line:

The correct format of repository source line is

<type of repository>  <location>  <dist-name> <components> 

For example, a repo line can be like this one

  deb http://archive.ubuntu.com/ubuntu precise main

Here, it means, the repository is for binary packages, which are hosted in http://archive.ubuntu.com/ubuntu and this repository is for Ubuntu precise (12.04) and this repository contains the main (software which are officially supported by Canonical) component.

  • Type: The type can be deb and deb-src. deb means a binary repository where deb-src means a source repository

  • Location: http://archive.ubuntu.com/ubuntu location of the repository.

  • Dist-name: The distribution name of Ubuntu release. For Ubuntu 12.04 it is precise, for 11.10 it is oneiric.

  • Component: It can be main, universe, multiverse and restricted. These words indicates the level of supports for the packages and the licensing status.

See this page for more information.

Please take note that, you can add one or more component in a line, so "main", "universe", "restricted" and "multiverse" can be in a single line. Also note, Though you add more than one component in a single line, APT system considers them as seperate line containing only one component.

So, If your sources.list have a line like this

deb http://archive.ubuntu.com/ubuntu precise universe

Then it can't have another line like the below (which your files have)

deb http://archive.ubuntu.com/ubuntu precise main universe

which is equivalent of these two lines

deb http://archive.ubuntu.com/ubuntu precise main
deb http://archive.ubuntu.com/ubuntu precise universe

Because, you are duplicating universe twice, so there will be an error for that duplicate. An error is given for each duplicate found and your file has 6 duplicates there.

Solution:

After analyzing your sources.list file, I found that, It is a basic one which is supplied by Ubuntu by default. You can build a default file following the procedure:

  1. Open a terminal and first rename the existing sources.list file to sources.list.bak file. (we can safely remove that, but caution is good).

     sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
    
  2. Then open software-properties-gtk to build a new one. Type the below command in a terminal or in dash command prompt with pressing Alt+F2

    software-properties-gtk
    

    Note, for Ubuntu version 11.10 or earlier you have to use gksu before the software-properties-gtk command

  3. After the window is open,

    • Select all four catagory in Ubuntu Software tab
    • Select precise-security, precise-updates and precise-backports catagory in Updates tab.
    • Select Canonical partner and Intependent catagory from Other software tab.

That's it. You have now a default sources.list file without error. Compare this file with the previous one, if you want.


Update to deal with sources.list.d dir's files

Sometimes a duplicate entry can be in a file in the /etc/apt/sources.list.d directory, which is also used byt APT. So, you should look at that directory and see if there is any duplicate in those files. It is not necessary for duplicats being in the same file.

Example case:

A user had this error message showing while doing sudo apt-get update.

W: Duplicate sources.list entry http://dl.google.com/linux/chrome/deb/ stable/main amd64 Packages (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://dl.google.com/linux/chrome/deb/ stable/main i386 Packages (/var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems

But there was no entry with http://dl.google.com in the main /etc/apt/sources.list file. Looking at the /etc/apt/sources.list.d/ directory we found these files:

output of ls /etc/apt/sources.list.d/:

aims-sagemath-precise.list
aims-sagemath-precise.list.save
dropbox.list
dropbox.list.save
fossfreedom-packagefixes-precise.list
fossfreedom-packagefixes-precise.list.save
google-chrome.list
google-chrome.list.save
google.list
google.list.save
sagemath-monolithic-precise.list
sagemath-monolithic-precise.list.save

The files google-chrome.list and google.list looked promising for containing duplicates. So, investing the content of both files were necessary

Output of cat /etc/apt/sources.list.d/google-chrome.list:

deb http://dl.google.com/linux/chrome/deb/ stable main  

and of cat /etc/apt/sources.list.d/google.list

deb http://dl.google.com/linux/chrome/deb/ stable main

So, there was a duplicate entries in the sources of Apt. Since google-chrome.list only contain a single apt line and it was also listed in google.list file we can safely remove this file with the command

sudo rm /etc/apt/sources.list.d/google-chrome.list

Then the problem was solved

share|improve this answer
1  
+1 This is a great answer. Fixed the problem and fully explained what why it had occurred. – akmad Apr 27 at 9:13
S="/etc/apt/sources.list" ;
S2="$S ${S}.d/*.list" ;
grep -b "^deb\`cat $S2 |
    grep -i "^deb[[:space:]]http" |
    sort |
    uniq -dc |
    sed -e 's;[[:space:]]\\+[[:digit:]]\\+[[:space:]]\\+deb\\(.\\+$\\);\\1;g'\`$" $S2

* Line breaks inserted for readability.

share|improve this answer
2  
Please explain the answer or risk having it removed. – jokerdino Jul 4 '12 at 4:55
Welcome to Ask Ubuntu! As jokerdino as indicated, this answer would benefit substantially, if you were to edit it to add some explanation (or at least to tell the user exactly what to do with these lines). – Eliah Kagan Jul 4 '12 at 10:34
This answer is wrong because it may does remove duplicate entries but it does not remove duplicate source entries. see here for an explanation – Anwar Sep 6 '12 at 5:26

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.