This topic describes how to add repositories to different Linux distributions by using Alibaba Cloud software repositories. Software packages for Linux are often stored in software repositories. After you add a repository, you can use the package management tool provided by Linux to search for, install, and update software applications in the repository.

Background information

Note Both Alibaba Cloud users and non-users have free access to Alibaba Cloud software repositories. You can go to the Alibaba Open Source Image Site to obtain the software repository of the Linux distribution.

Add a software repository to CentOS

The following section describes how to add a software repository to CentOS 7. Operations may vary depending on the version of your operating system. Perform the following steps:

  1. Connect to a Linux instance. For more information, see Connection methods.
  2. Run the following command to back up the original software repository:
    sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  3. Run one of the following commands to add a software repository to CentOS 7:
    • sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    • sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    Note
    • If you want to add an Alibaba Cloud software repository to other versions of CentOS, go to the Alibaba Open Source Image Site, find centos, and click Help.
    • If you want to add a software repository that is not from Alibaba Cloud, replace http://mirrors.aliyun.com/repo/Centos-7.repo in the preceding commands with the URL of the software repository that you want to add.
  4. Run the following command to generate a local cache for faster searching for and installation of software:
    sudo yum clean all && sudo yum makecache
  5. Run the sudo yum repolist command to check whether the software repository is added.
    After you add an Alibaba Cloud software repository to CentOS 7, the system displays the following information.

Add a software repository to Ubuntu

The following section describes how to add a software repository to the Ubuntu 18.04 operating system. Operations may vary depending on the version of your operating system. Perform the following steps:

  1. Connect to a Linux instance. For more information, see Connection methods.
  2. Run the following command to back up the original software repository:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakup
  3. Run the sudo vim/etc/apt/sources.list command to open the file and add the following information to the file. For more information about how to add the information, see Use the Vim editor.
    deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-backports main restricted universe multiverse
    Note
    • If you want to add an Alibaba Cloud software repository to other versions of Ubuntu, go to the Alibaba Open Source Image Site, find ubuntu, and click Help. If you want to add an Alibaba Cloud software repository to an ECS instance, replace http://mirrors.aliyun.com/ubuntu/ on the Help page with http://mirrors.cloud.aliyuncs.com/ubuntu. This helps save data transfer costs.
    • If you want to add a software repository that is not from Alibaba Cloud, replace the URL on the Help page with the URL of the software repository that you want to add.
  4. Run the sudo apt-get update command to update the information about software packages.

Add a software repository to Debian

The following section describes how to add a software repository to Debian 8.9. Operations may vary depending on the version of your operating system. Perform the following steps:

  1. Connect to a Linux instance. For more information, see Connection methods.
  2. Run the following command to back up the original software repository:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakup
  3. Run the sudo vim/etc/apt/sources.list command to open the file and add the following information to the file. For more information about how to add the information, see Use the Vim editor.
    deb http://mirrors.cloud.aliyuncs.com/debian/ jessie main non-free contrib
    deb http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
    deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie main non-free contrib
    deb-src http://mirrors.cloud.aliyuncs.com/debian/ jessie-proposed-updates main non-free contrib
    Note
    • If you want to add an Alibaba Cloud software repository to other versions of Debian, go to the Alibaba Open Source Image Site, find debian, and click Help. If you want to add an Alibaba Cloud software repository to an ECS instance, replace http://mirrors.aliyun.com/debian/ on the Help page with http://mirrors.cloud.aliyuncs.com/debian/. This helps save data transfer costs.
    • If you want to add a software repository that is not from Alibaba Cloud, replace the URL on the Help page with the URL of the software repository that you want to add.
  4. Run the sudo apt-get update command to update the information about software packages.

Add a software repository to Fedora

  1. Run the following commands to back up the original software repository:
    # sudo mv /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/fedora.repo.backup
    # sudo mv /etc/yum.repos.d/fedora-updates.repo /etc/yum.repos.d/fedora-updates.repo.backup
  2. Run one of the following commands to add a fedora repository of Alibaba Cloud:
    • sudo wget -O /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo
    • sudo curl -o /etc/yum.repos.d/fedora.repo http://mirrors.aliyun.com/repo/fedora.repo
    Note If you want to add a software repository that is not from Alibaba Cloud, replace http://mirrors.aliyun.com/repo/fedora.repo in the preceding commands with the URL of the software repository that you want to add.
  3. Run one of the following commands to add a fedora-updates repository of Alibaba Cloud:
    • sudo wget -O /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo
    • sudo curl -o /etc/yum.repos.d/fedora-updates.repo http://mirrors.aliyun.com/repo/fedora-updates.repo
      Note If you want to add a fedora-updates software repository that is not from Alibaba Cloud, replace http://mirrors.aliyun.com/repo/fedora-updates.repo in the commands with the URL of the software repository that you want to add.
  4. Run the following command to generate a local cache:
    sudo yum clean all && sudo yum makecache

What to do next

After you add a software repository, you can install software packages. For more information, see Install software packages.