Ubuntu systems rely on apt repositories distributed across various mirrors. The default mirror is typically based on the country selected during installation, reflecting ISO 3166 country codes. This arrangement leverages localized servers to reduce network latency and expedite package downloads.
Altering the apt repository source is often essential when facing network bottlenecks, resolving accessibility constraints, or complying with organizational requirements. Adjusting these sources can improve download performance and ensure alignment with system policies.
Precise control over the apt source list allows systems to retrieve packages from the most suitable mirrors. Configuring the right mirror helps optimize update speeds, reduces the likelihood of errors, and maintains stability on Ubuntu platforms.
Related: Official Archive Mirrors for Ubuntu
Related: List of ISO 3166 country codes
Steps to change apt source in Ubuntu using the GUI:
- Open the “Software & Updates” utility from the application menu.
- Select the “Ubuntu Software” tab in “Software & Updates.”
- Choose “Download from:” and select the desired server or mirror from the dropdown list.
- Click “Close” to save changes and reload the package information when prompted.
Ubuntu may ask to reload package lists immediately after selecting a new download source.
Steps to change apt source in Ubuntu from terminal:
- Open the terminal.
- Create a backup of the apt source file (optional).
$ sudo cp -a /etc/apt/source.list /etc/apt/source.list.bak [sudo] password for user:
- Open the apt source file in a text editor.
- Change the source or country of the apt repositories.
Replaces all instances of the Japanese repository URLs with the US ones in the apt sources list using sed directly at the terminal.
$ sudo sed -i "s/\/jp\./\/us\./g" /etc/apt/sources.list
- Update the apt package list from the new repositories.
$ sudo apt update Hit:1 http://ports.ubuntu.com/ubuntu-ports kinetic-security InRelease Get:2 http://us.ports.ubuntu.com/ubuntu-ports kinetic InRelease [267 kB] Get:3 http://us.ports.ubuntu.com/ubuntu-ports kinetic-updates InRelease [90.7 kB] Get:4 http://us.ports.ubuntu.com/ubuntu-ports kinetic-backports InRelease [90.7 kB] Get:5 http://us.ports.ubuntu.com/ubuntu-ports kinetic/main arm64 Packages [1,363 kB] ##### snipped
Step for apt update (above) is crucial before proceeding with package upgrade or installation.
- Upgrade the installed packages to ensure they are using the new sources.
$ sudo apt dist-upgrade --assume-yes
This guide is tested on Ubuntu:
Version | Code Name |
---|---|
22.04 LTS | Jammy Jellyfish |
23.10 | Mantic Minotaur |
24.04 LTS | Noble Numbat |

Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.