In most cases, software packages for Linux are stored in software repositories. After you add a software repository, you can use the package management tool provided by Linux to search for, install, and update software applications in the repository. This topic describes how to add software repositories for different Linux distributions. In these examples, Alibaba Cloud software repositories are used.
Background information
All users (even those without Alibaba Cloud accounts) can use Alibaba Cloud software repositories free of charge. You can go to the Alibaba Open Source Image Site to obtain the software repository of your Linux distribution.
This topic describes how to add a software repository to Elastic Compute Service (ECS) instances. If your server is not an ECS instance, replace the http://mirrors.cloud.aliyuncs.com
repository address with the http://mirrors.aliyun.com
repository address.
Procedure
Add a software repository to a CentOS instance
In this example, an ECS instance that runs a CentOS 7 operating system is used. Operations may vary based on the version of your operating system.
CentOS 6 and CentOS 8 have reached their end of life (EOL). In accordance with Linux community rules, all content has been removed from the CentOS 6 and CentOS 8 repository addresses. If you continue to use the default repository address of CentOS 6 or CentOS 8, an error is reported. We recommend that you change the repository address of CentOS 6 or CentOS 8. For more information, see Change the CentOS 6 source address and Change CentOS 8 repository addresses.
Connect to a Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
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
Run one of the following commands to add the Alibaba Cloud CentOS 7 software repository to the instance:
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/Centos-7.repo
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/Centos-7.repo
NoteTo add an Alibaba Cloud software repository to an instance that runs another version of CentOS, go to the Alibaba Open Source Image Site and click
centos
to learn the procedure.To add a software repository that is not from Alibaba Cloud, replace
http://mirrors.cloud.aliyuncs.com/repo-ecs/Centos-7.repo
in the preceding commands with the URL of the software repository that you want to add.
Run the following command to generate a local cache for fast search and installation of software:
sudo yum clean all && sudo yum makecache
Run the
sudo yum repolist
command to check whether the software repository is added.The following command output indicates that the Alibaba Cloud software repository is added to the CentOS 7 instance.
Add a software repository to an Ubuntu instance
In this example, an ECS instance that runs an Ubuntu 18.04 operating system is used. Operations may vary based on the version of your operating system.
Connect to a Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to back up the original software repository:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakup
Run the
sudo vim /etc/apt/sources.list
command to open the sources.list file and add the following information to the file.For information about how to add information to files, 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
NoteTo add an Alibaba Cloud software repository to an instance that runs another version of Ubuntu, go to the Alibaba Open Source Image Site and click
ubuntu
to learn the procedure. To add an Alibaba Cloud software repository to an ECS instance and reduce data transfer costs, replacehttp://mirrors.aliyun.com/ubuntu/
in the help document withhttp://mirrors.cloud.aliyuncs.com/ubuntu/
.To add a software repository that is not from Alibaba Cloud, replace the added information with the information of the software repository that you want to add.
Run the
sudo apt-get update
command to update software package information in the software repository.
Add a software repository to a Debian instance
In this example, an ECS instance that runs a Debian 8.9 operating system is used. Operations may vary based on the version of your operating system.
Connect to a Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to back up the original software repository:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bakup
Run the
sudo vim /etc/apt/sources.list
command to open the sources.list file and add the following information to the file.For information about how to add information to files, 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
NoteTo add an Alibaba Cloud software repository to an instance that runs another version of Debian, go to the Alibaba Open Source Image Site and click
debian
to learn the procedure. To add an Alibaba Cloud software repository to an ECS instance and reduce data transfer costs, replacehttp://mirrors.aliyun.com/debian/
in the help document withhttp://mirrors.cloud.aliyuncs.com/debian/
.To add a software repository that is not from Alibaba Cloud, replace the added information with the information of the software repository that you want to add.
Run the
sudo apt-get update
command to update software package information in the software repository.
Add a software repository to a Fedora instance
Connect to a Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
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
Run one of the following commands to add the Fedora software repository of Alibaba Cloud to the instance:
sudo wget -O /etc/yum.repos.d/fedora.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora.repo
sudo curl -o /etc/yum.repos.d/fedora.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora.repo
NoteTo add a Fedora software repository that is not from Alibaba Cloud, replace
http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora.repo
in the preceding commands with the URL of the software repository that you want to add.Run one of the following commands to add the fedora-updates software repository of Alibaba Cloud to the instance:
sudo wget -O /etc/yum.repos.d/fedora-updates.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora-updates.repo
sudo curl -o /etc/yum.repos.d/fedora-updates.repo http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora-updates.repo
NoteTo add a fedora-updates software repository that is not from Alibaba Cloud, replace
http://mirrors.cloud.aliyuncs.com/repo-ecs/fedora-updates.repo
in the preceding commands with the URL of the software repository that you want to add.
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.