How to change Ubuntu Repository Mirror Sources

Raeseok, Lee·2023년 7월 23일
0
post-thumbnail

When installing or updating packages, the download speed can vary greatly depending on the location of the mirror server. Especially, using a Ubuntu mirror server operated in Korea can significantly improve the download speed.

In this post, we will introduce two ways to change the mirror server: manually changing the mirror server and using a script that automatically changes the mirror server.

Manually Changing the Mirror Server

The following method is based on Ubuntu 20.04 LTS.

  1. Open the terminal and enter the following command. This command opens the sources.list file with administrator privileges.
sudo nano /etc/apt/sources.list
  1. Once the sources.list file is opened, find the address of the mirror server currently in use. You can usually find a line that starts with http://archive.ubuntu.com or http://kr.archive.ubuntu.com.

  2. Deactivate the current server address through annotation (lines starting with the hash(#) symbol).

  3. Add the Korean server mirror address. Add the following address to the sources.list file.

deb http://mirror.kakao.com/ubuntu/ focal main restricted
deb http://mirror.kakao.com/ubuntu/ focal-updates main restricted
deb http://mirror.kakao.com/ubuntu/ focal universe
deb http://mirror.kakao.com/ubuntu/ focal-updates universe
deb http://mirror.kakao.com/ubuntu/ focal multiverse
deb http://mirror.kakao.com/ubuntu/ focal-updates multiverse
deb http://mirror.kakao.com/ubuntu/ focal-backports main restricted universe multiverse
  1. To close the editor and save after saving, press Ctrl + X, and to save the changes, enter Y and press enter.

  2. Update the repository. Run the following command in the terminal.

sudo apt update

Done! :)

Automatically Changing the Mirror Server Using a Script

Manually changing the mirror server is simple, but requires several steps. Instead, we have developed a script that automates this process.

This script is uploaded on GitHub and can be downloaded from the following link:
Mirror Manager Script Download Link
Script Github repository

  1. Download the script from the link above.

  2. Grant execution permissions to the downloaded script. Run the following command in the terminal.

chmod +x mirror_manager.sh
  1. Run the script. Enter the following command in the terminal.
./mirror_manager.sh

When the script runs, it displays a list of available mirror servers. If you select the mirror server you want, the script automatically modifies the sources.list file and updates the repository.

profile
fullstack. devops.

0개의 댓글