I keep getting this warning whenever I try to run sudo apt-get update
.
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ precise-updates/main i386 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_precise-updates_main_binary-i386_Packages)
W: You may want to run apt-get update to correct these problems
Below is the output from /etc/apt/sources.list
file:
deb http://archive.ubuntu.com/ubuntu precise main restricted
deb-src http://archive.ubuntu.com/ubuntu precise main restricted
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted
deb http://archive.ubuntu.com/ubuntu precise universe
deb-src http://archive.ubuntu.com/ubuntu precise universe
deb http://archive.ubuntu.com/ubuntu precise-updates universe
deb-src http://archive.ubuntu.com/ubuntu precise-updates universe
deb http://archive.ubuntu.com/ubuntu precise multiverse
deb-src http://archive.ubuntu.com/ubuntu precise multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-updates multiverse
deb http://archive.ubuntu.com/ubuntu precise-security main restricted
deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted
deb http://archive.ubuntu.com/ubuntu precise-security universe
deb-src http://archive.ubuntu.com/ubuntu precise-security universe
deb http://archive.ubuntu.com/ubuntu precise-security multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-security multiverse
How do I fix it?
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
For example, a repo line can be like this one
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
anddeb-src
.deb
means a binary repository wheredeb-src
means a source repositoryLocation:
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 isoneiric
.You can visit the Ubuntu Wiki to view an updated list of Ubuntu releases and their code names.
Component: It can be
main
,universe
,multiverse
andrestricted
. 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 separate line containing only one component.
So, If your
sources.list
have a line like thisThen it can't have another line like the below (which your files have)
which is equivalent of these two lines
Because, you are duplicating universe twice, so there will be an error for that duplicate. An error will be given for each duplicate found.
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:Open a terminal and first rename the existing
sources.list
file tosources.list.bak
file. (we can safely remove that, but caution is good).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+F2Note, for Ubuntu version 11.10 or earlier you have to use
gksu
before thesoftware-properties-gtk
commandAfter the window is open,
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 filesSometimes a duplicate entry can be in a file in the
/etc/apt/sources.list.d
directory, which is also used by APT. So, you should look at that directory and see if there is any duplicate in those files. It is not necessary for duplicates being in the same file.Example case:
A user had this error message showing while doing
sudo apt-get update
.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/
:The files
google-chrome.list
andgoogle.list
were good candidates for containing duplicates. So, checking the contents of both files was necessary.Output of
cat /etc/apt/sources.list.d/google-chrome.list
:and of
cat /etc/apt/sources.list.d/google.list
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 ingoogle.list
file we can safely remove this file with the commandThen the problem was solved.
For Ubuntu 12.04
Graphically:
Press Alt + F2 and paste
software-properties-gtk
(or you can open "Software Center" then go to "Edit" > "Software Sources"). Go to tab "Other Software", choose the duplicate entry and press the "Remove" button.If you need a command line option, here it is:
The command does this:
cat
reads the file and passes the content toperl
which removes the duplicate lines. The result is then saved>
in a temporary file which is then moved to replace the original/etc/apt/sources.list
file.How bad are duplicate entries in sources.list?
I don’t know how bad it is, but i don’t like sudo apt-get update showing me duplicate entries.
By the way its not that bad, its just showing you that you have duplicate entries.
SourcesList
The sources.list file is a key factor in adding or upgrading applications to your Ubuntu installation. This is also used by your system for system updates. The file is basically the roadmap for your system to know where it may download programs for installation or upgrade.
Its just like Windows update
Open y-ppa-manager form Dash
The partner repository is duplicated inside
/etc/apt/sources.list
and/etc/apt/sources.list.d/precise-partner.list
.Just remove those "precise-partner" files as the partner repository is already present in
sources.list
.Make a back up copy of your sources.list:
Now remove the original and update:
I had the same problem, open software sources. unchecked "Canonical Partners". The Conflict is between "Canonical Partners" and " Canonical partners Added by software Center"
If you couldn't figure it out in your
source.list
, then do this:sudo apt-get update
.10.10 and Earlier
Applications > Ubuntu Software Center > Edit > Software Sources > Other Software
OR
System > Administration > Synaptic Packet Manager > Settings > Repositories
Select and Remove duplicate entries.
For Ubuntu 9.10 - 12.04
There is an app called Y-PPA-Manager which can do that and much more.
You can install it like that from a Terminal:
After that, just start the application an go to the Advanced menu.
Then select "Scan and remove duplicate PPAs" and hit OK.
I searched for such a tool, but I didn't find any...
So, I ended up coding one myself with
PHP
.Sorry for the dirty unorganized source code.
chkdup - Screenshot:
Author
Mubarak Alrashidi (DeaDSouL)
Requirements:
Installation:
sudo apt-get install php5 php5-cli
.sudo sh install.sh
.Uninstall:
sudo sh uninstall.sh
.How to use it:
Just open the terminal and type
sudo chkdup
.FAQs:
What does the install.sh do ?
chkdup.php
to/opt/
then will create a symbolic link in/usr/bin/
.What about the uninstall.sh ?
The uninstaller will remove the following files:
install.sh
/opt/chkdup.php
/usr/bin/chkdup
uninstall.sh
Is it safe to use chkdup ?
License
GNU General Public License