Ubuntu, by default, will use the apt repository local to the country you set when installing your Ubuntu system. There are repositories set up for each country, where the URL are differentiated based on the 2 characters (Alpha-2) country code. Some repositories are not country-specific that you can also use, and it's possible even to set one up on your own.

Multiple apt repositories ensure the main repository is not overwhelmed by global requests and for a more seamless user experience, as local repositories are generally faster than those in foreign countries due to network latency.

You might want to change the source for your apt repository for any technical (bandwidth issues) or non-technical (corporate policy) reasons. You can do that by updating the apt repository source file from the terminal.

Steps to change apt source in Ubuntu:

  1. Launch terminal.
  2. Backup apt source file (optional).
    $ sudo cp -a /etc/apt/source.list /etc/apt/source.list.bak
    [sudo] password for user: 
  3. Change the source or just the country of apt repositories using sed or your favorite text editor.
    $ sudo sed -i "s/\/jp\./\/us\./g" /etc/apt/sources.list
  4. Update apt package list from the new apt 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.

  5. Upgrade installed packages using the new repositories.
    $ sudo apt dist-upgrade --assume-yes
Discuss the article:

Comment anonymously. Login not required.