A record related to adding APT repositories and modifying mirror sources

Image credit: Debian Logo

Table of Contents

Add repository

Tools required for installation

First execute the following statement.

  apt install software-properties-common

After the installation is complete, executable files named add-apt-repository and apt-add-repository will be added in /usr/bin, The latter is a linked file and points to the former, so either one of the two can be used in actual use.

  ≻ ls -l /usr/bin | grep repository
  -rwxr-xr-x 1 root   root        7415  1月 27 06:30 add-apt-repository
  lrwxrwxrwx 1 root   root          18  1月 27 06:30 apt-add-repository -> add-apt-repository

Add repository

To add Emacs and fish as an example, execute the following statement.

  add-apt-repository ppa:kelleyk/emacs
  add-apt-repository ppa:fish-shell/release-3

Refresh the software index

  apt update

Install the corresponding software

  apt install emacs27
  apt install fish

Modify APT source to improve download speed

General plan

When the official source cannot be accessed or the download speed is slow due to geographic or network issues, the server for apt command can be modified to another mirror server. Take the change to Huawei mirror server as an example, execute the following statement.

  cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
  sed -i "s@http://.*archive.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list
  sed -i "s@http://.*security.ubuntu.com@http://repo.huaweicloud.com@g" /etc/apt/sources.list
  apt update

Solution for ARM64

Some APT mirror sources are not updated in time, and the system architecture is not fully supported. For the ARM64 architecture, many APT sources in China's mainland have this problem. For example, When Ubuntu running on a Jetson Nano development board.

After testing, the APT mirror source provided by Huawei supports the ARM64 architecture well. Execute the following statement to change to Huawei source.

  cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
  wget -O /etc/apt/sources.list https://repo.huaweicloud.com/repository/conf/Ubuntu-Ports-bionic.list
  apt update

Edit this page

Xin Li
Xin Li
Lecturer

Research in areas such as machine learning, deep learning, and artificial intelligence applications, specialize in priority sampling and learning algorithm for non-uniform data and offset data.Learn more

comments powered by Disqus
Next
Previous

Related