Ubuntu升级报错求助:从17.04升级至17.10提示sources.list重复配置
Hey, I’ve helped a bunch of folks work through this exact duplicate source issue during Ubuntu upgrades—let’s get this sorted out step by step.
Step 1: Identify the Duplicate Entries
First, let’s pin down which sources are causing the conflict. Run this command to trigger the error and capture the problematic URLs:
sudo apt update
You’ll see warnings like:
W: Duplicate sources.list entry http://archive.ubuntu.com/ubuntu/ zesty/main amd64 Packages (/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_zesty_main_binary-amd64_Packages)
Copy the URL part (e.g., http://archive.ubuntu.com/ubuntu/ zesty/main) from the warning—we’ll use this to track down where it’s duplicated.
Step 2: Locate Where the Duplicates Live
Source configurations aren’t just in /etc/apt/sources.list—they can also hide in files under /etc/apt/sources.list.d/. Use this command to find all files containing the duplicate entry:
grep -r "http://archive.ubuntu.com/ubuntu/ zesty/main" /etc/apt/sources.list /etc/apt/sources.list.d/
This will output lines like:
/etc/apt/sources.list:deb http://archive.ubuntu.com/ubuntu zesty main
/etc/apt/sources.list.d/custom-repo.list:deb http://archive.ubuntu.com/ubuntu zesty main
Now you know exactly which files have the duplicate lines.
Step 3: Clean Up the Duplicates
Open each file with a text editor (I prefer nano for simplicity) and remove the extra duplicate lines. Keep only one instance of each source entry—don’t delete both, you need at least one to keep the repository active.
For the main sources.list file:
sudo nano /etc/apt/sources.list
For a file in sources.list.d:
sudo nano /etc/apt/sources.list.d/custom-repo.list
Once you’ve deleted the duplicates, save the file (in nano, press Ctrl+O, then Enter, then Ctrl+X to exit).
Step 4: Verify and Proceed with Upgrade
Run sudo apt update again—if you don’t see any duplicate entry warnings, you’re good to go! Now start the upgrade process:
sudo do-release-upgrade
Quick Heads-Up
Ubuntu 17.10 (Artful Aardvark) reached its end of life a while back, meaning it no longer gets security updates or support. Once you successfully upgrade to 17.10, I strongly recommend upgrading again to a long-term support (LTS) version like Ubuntu 18.04 LTS to keep your system secure and maintained.
内容的提问来源于stack exchange,提问作者Suhail

