The 'Duplicate sources.list entry' warning appears when apt finds the same repository configured twice in your system. This typically happens when PPAs, Chrome, or other software auto-register repositories in multiple locations. While not critical, duplicates cause unnecessary package index updates and confusion.
The "Duplicate sources.list entry" warning indicates that apt has detected the same software repository configured more than once on your system. This warning occurs because: - The same repository appears in multiple locations (/etc/apt/sources.list and /etc/apt/sources.list.d/*.list files) - Software packages like Google Chrome automatically create source files that duplicate existing entries - Manual PPA additions or configuration management tools may add the same source twice - Third-party installers may add repositories without checking for duplicates This is a **warning, not an error**. Your system will still function normally and download packages correctly. However, apt will process the duplicate entry twice during each update, wasting bandwidth and time.
First, identify which repository is duplicated. The apt warning shows which entry is repeated:
sudo apt-get update
# Output shows: W: Duplicate sources.list entry https://dl.google.com/linux/direct/deb/ stable ReleaseNote the exact URL or PPA name from the warning message.
The duplicate can be in either /etc/apt/sources.list or in /etc/apt/sources.list.d/ directory:
# Check the main sources list
grep -n "duplicate-url" /etc/apt/sources.list
# Check all .list files in sources.list.d
grep -r "duplicate-url" /etc/apt/sources.list.d/Example output might show the same repository in multiple files.
Open the file containing the duplicate and comment it out with a # symbol:
# For duplicates in the main file:
sudo nano /etc/apt/sources.list
# Find the duplicate line and add # at the beginning:
# deb https://dl.google.com/linux/direct/deb/ stable main
# Save (Ctrl+O, Enter, Ctrl+X)
# For duplicates in sources.list.d/ files:
sudo nano /etc/apt/sources.list.d/google-chrome.listAfter editing, test the fix:
sudo apt-get update
# Warning should be goneIf the duplicate is in a separate file in /etc/apt/sources.list.d/, you can delete the entire file:
# List files in sources.list.d
ls -la /etc/apt/sources.list.d/
# Remove the duplicate file (example)
sudo rm /etc/apt/sources.list.d/google.list
# Or for a more specific match:
sudo rm /etc/apt/sources.list.d/google-chrome.listThis is safe because:
- You're only removing one of the duplicate entries
- The software still has its source configured in the other location
- The package manager will continue to work normally
Verify the fix:
sudo apt-get updateFor multiple duplicates or complex setups, use grep to identify all instances:
# Find all duplicate sources
grep -r "specific-url" /etc/apt/sources.list*
# Example: Find all Google Chrome sources
grep -r "dl.google.com/linux/direct" /etc/apt/sources.list*This shows you exactly where duplicates exist. Then manually edit the files shown.
Advanced: Use a one-liner to check for all duplicates
# Combine all sources and find duplicates
cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null | \
grep -v "^#" | grep -v "^$" | sort | uniq -dThis shows only lines that appear more than once.
If you prefer a graphical approach on Ubuntu/Linux Mint:
1. Open "Software Sources" from the application menu
2. Click on the "Other Software" tab
3. Look through the list for duplicate entries
4. Select the duplicate and click "Remove"
5. Close the dialog and run update
This method is safer because the GUI prevents accidental syntax errors.
Configure your system to avoid adding duplicate sources:
# Before adding a PPA, check if it already exists
grep -r "ppa:name/ppa" /etc/apt/sources.list*
# If found, don't add it again
# When installing software that adds its own repo:
# 1. Check what repo will be added
# 2. Verify it doesn't already exist
# 3. Only proceed if necessaryFor automation (deployment scripts):
#!/bin/bash
# Only add the source if it doesn't exist
if ! grep -q "repository-url" /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null; then
sudo add-apt-repository -y ppa:name/ppa
sudo apt-get update
fiThis prevents duplicates from being added by automation tools.
After removing duplicates, verify the fix:
# Run update and check for warnings
sudo apt-get update
# Count total sources
wc -l /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null
# List all enabled sources (no duplicates)
grep -v "^#" /etc/apt/sources.list /etc/apt/sources.list.d/*.list 2>/dev/null | \
grep -v "^$" | sort -uThe output should show no duplicate warnings and a clean list of sources.
Understanding apt Sources
The apt package manager looks for repositories in two places:
- /etc/apt/sources.list - The main configuration file (legacy)
- /etc/apt/sources.list.d/ - Directory for additional sources (modern approach)
When you add a PPA with add-apt-repository, it creates a new .list file in sources.list.d/ directory. This modular approach is cleaner than editing the main file.
How Duplicates Happen
Software vendors often auto-register their repositories:
- Google Chrome: Creates google-chrome.list on installation
- Microsoft: Creates multiple files for VS Code, Edge, etc.
- Slack: Adds slack.list automatically
- Ubuntu: Some upgrades may re-add existing sources
If a user manually adds the same PPA before the software is installed (or if upgrading a system), duplicates can occur.
Performance Impact
Each duplicate source causes apt to:
1. Download the repository's package index
2. Merge it with existing packages
3. Process the redundant metadata
This adds roughly 10-30 seconds per duplicate during apt-get update, making system updates slower.
Safety Considerations
- Safe to remove: Duplicates can be safely removed without breaking anything
- Keep one copy: Always keep at least one copy of the source
- Test after removal: Run apt-get update to verify nothing breaks
- Common mistake: Some users accidentally remove ALL copies of a needed source
Detecting Auto-Added Repositories
Software often adds sources without your knowledge. Check timestamps:
ls -lt /etc/apt/sources.list.d/
# Newest files are recently added repositoriesReview unexpected .list files and remove if you didn't explicitly add them.
Automating Cleanup (Advanced)
For system administrators managing multiple machines:
#!/bin/bash
# Remove duplicates from all source lists
{
cat /etc/apt/sources.list
cat /etc/apt/sources.list.d/*.list 2>/dev/null
} | grep -v "^#" | grep -v "^$" | sort | uniq | \
tee /tmp/unique-sources.txt
# Then reconstruct sources.list with unique entries
# (requires careful handling to avoid breaking the system)This is complex and not recommended unless you fully understand apt configuration.
Comparing with Other Package Managers
| Package Manager | Source Config | Duplicate Handling |
|-----------------|----------------|--------------------|
| apt (Debian/Ubuntu) | /etc/apt/sources.list + .d/ | Shows warnings |
| yum (RedHat/CentOS) | /etc/yum.repos.d/ | Ignores duplicates |
| pacman (Arch) | /etc/pacman.conf | Ignores duplicates |
| dnf (Fedora) | /etc/yum.repos.d/ | Ignores duplicates |
apt is more verbose about duplicates than other package managers.
Related apt Issues
If you see similar warnings:
- "Target Packages is configured multiple times" - Same root cause
- "Target Release is configured multiple times" - Same repository with different releases
- "Target InRelease is configured multiple times" - Metadata conflicts
E: Cannot set to hold: package 'package-name' is not installed
How to fix "Cannot set to hold" error when package is not installed in APT
debconf: unable to initialize frontend: Dialog
How to fix "debconf: unable to initialize frontend: Dialog" in APT
E: Could not connect to proxy server
Could not connect to proxy server
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Package 'package:i386' has no installation candidate
How to fix "Package package:i386 has no installation candidate" in apt