Skip to Content
DocsOperationsSystem AdministrationMirrors and apt Sources

Switching to a Mirror: deb822 and apt Sources

Since 24.04 the Ubuntu package sources no longer live in /etc/apt/sources.list; they moved to /etc/apt/sources.list.d/ubuntu.sources in the deb822 format. Plenty of guides still tell you to edit sources.list, and on 26.04 that simply does nothing.

Look at the file first

head -12 /etc/apt/sources.list.d/ubuntu.sources
A terminal running head on ubuntu.sources, showing two deb822 stanzas: the first with Types deb, URIs cn.archive.ubuntu.com and Suites resolute resolute-updates resolute-backports, the second with security.ubuntu.com and resolute-security
The real file on 26.04: two deb822 stanzas and the resolute codename

On 26.04 it looks like this — two stanzas, the main archive and the security channel:

Types: deb URIs: http://cn.archive.ubuntu.com/ubuntu/ Suites: resolute resolute-updates resolute-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: resolute-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg

What the fields mean:

FieldMeaning
TypesRepository kind; deb is binary packages (deb-src is source)
URIsThe line you change — the mirror address
SuitesRelease codename: resolute is 26.04; -updates, -security and -backports are the channels
ComponentsPackage sections: main restricted universe multiverse
Signed-ByVerification key — leave it alone
Note

26.04 already points at cn.archive.ubuntu.com, so Chinese users start on a mirror. Switching to Aliyun or TUNA is about speed and reliability (the official China mirror can lag), not about making apt work at all.

Changing the mirror: URIs only

The rule: touch URIs only. A wrong codename in Suites and you get 404s.

Back up first:

sudo cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak

Then replace (Aliyun here):

sudo sed -i -E 's|(cn\.)?archive\.ubuntu\.com|mirrors.aliyun.com|g; s|security\.ubuntu\.com|mirrors.aliyun.com|g' \ /etc/apt/sources.list.d/ubuntu.sources

Verify:

sudo apt update

If the Hit/Get lines come back from the new host without 404 or Release file errors, you are done.

Common mirrors

Swap mirrors.aliyun.com in the command above for any of these:

MirrorHost
Aliyunmirrors.aliyun.com
Tsinghua TUNAmirrors.tuna.tsinghua.edu.cn
USTCmirrors.ustc.edu.cn
Huawei Cloudmirrors.huaweicloud.com

Rolling back

If apt update fails after the change, one command restores the original:

sudo cp /etc/apt/sources.list.d/ubuntu.sources.bak /etc/apt/sources.list.d/ubuntu.sources sudo apt update

That is why the backup step is not optional.

Is there still a GUI for this?

Not in the default set. 26.04 does not ship Software & Updates (software-properties-gtk); searching for “software” opens the App Center, which only handles Snaps and cannot edit apt sources.

So the click-through workflow no longer exists on 26.04. Use the commands above, or install the old panel if you really want it:

sudo apt install software-properties-gtk

PPAs are not mirrors

Changing the mirror only affects the official Ubuntu archive. PPAs you added with add-apt-repository ppa:xxx/yyy live in their own .list or .sources files under /etc/apt/sources.list.d/ and keep connecting to launchpad directly.

If a PPA is slow from your network, the only options are a project-specific mirror or a proxy.

Common errors

404 Not Found or “does not have a Release file”

The codename in Suites is wrong, or the mirror has not synced that release yet. 26.04 is resolute — not noble (24.04) and not plucky (25.04).

NO_PUBKEY or “signatures couldn’t be verified”

Unrelated to the mirror: a PPA key is missing. Import the id from the error message:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY_ID>

The cleaner approach is storing the key under /usr/share/keyrings/ and referencing it with Signed-By; apt-key is deprecated in current releases.

“Release file … is not valid yet”

The system clock is off. Check timedatectl and enable time sync:

sudo timedatectl set-ntp true
Last updated on