In Linux, software packages are stored in repositories. After you add a repository, you can use the package manager of your Linux system to find, install, or update software from the repository. This helps you quickly perform operations and maintenance (O&M) tasks or meet your application development needs. This topic uses an Alibaba Cloud software source as an example and describes how to manage and use software sources on different Linux distributions.
Background information
The access speed of a software source is affected by factors such as region and distance. The Alibaba Cloud Open Source Mirror Site provides a free, high-speed, one-stop mirror service for Internet users. It provides software source mirrors for mainstream distributions, such as CentOS, Debian, Ubuntu, Fedora, and openSUSE. This software source is free for both Alibaba Cloud and non-Alibaba Cloud users. For more information, see the Alibaba Cloud Open Source Mirror Site.
Important For public images provided by Alibaba Cloud, the software sources for common Linux distributions are replaced with the internal repository addresses of the Alibaba Cloud Mirror Site by default. ECS users can use these sources directly without manual configuration. To manually add or fix a software source for a Linux distribution, you can follow the steps in this topic.
The mirror address added in this topic is the public repository address of the Alibaba Cloud Mirror Site, http://mirrors.aliyun.com. This address is for Linux systems that have public network access. If your server is an Alibaba Cloud ECS instance, you can use the internal repository address of the Alibaba Cloud Mirror Site, http://mirrors.cloud.aliyuncs.com, to obtain faster download speeds.
Add an Alibaba Cloud software source to a Linux instance
Connect to the Linux instance
For more information, see Log on to a Linux instance using Workbench. This topic uses the ecs-user user to log on to the target host as an example. You can use other logon methods.
Add the Alibaba Cloud software source
Note The following sections describe how to add an Alibaba Cloud software source for several common Linux distributions. The actual steps may vary based on your operating system version. To add an Alibaba Cloud software source for other Linux distributions, go to the Alibaba Cloud Open Source Mirror Site, find your operating system, and click it to view the specific steps.
Alibaba Cloud Linux 3/2
Run the following command to back up the original software source.
sudo mv /etc/yum.repos.d/AliYun.repo /etc/yum.repos.d/AliYun.repo.backup
Run the following command to add the software source.
Alibaba Cloud Linux 3
sudo rpm -Uvh --reinstall https://mirrors.aliyun.com/alinux/3/updates/x86_64/Packages/alinux-repos-3.2104.10-2.al8.x86_64.rpm
Alibaba Cloud Linux 2
sudo rpm -Uvh --reinstall https://mirrors.aliyun.com/alinux/2/updates/x86_64/Packages/alinux-release-2.1903-11.al7.x86_64.rpm
Run the following command to generate a local cache. This speeds up software searches and installations.
sudo yum clean all && sudo yum makecache
CentOS 8/7/6
Run the following command to back up the original software source.
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
Run the following command to add the Alibaba Cloud software source.
CentOS 8
url=https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo;if [ -f /usr/bin/curl ];then sudo curl -sSO $url;else sudo wget -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo $url; fi
CentOS 7
url=https://mirrors.aliyun.com/repo/Centos-7.repo;if [ -f /usr/bin/curl ];then sudo curl -sSO $url;else sudo wget -O /etc/yum.repos.d/Centos-7.repo $url; fi
CentOS 6
url=https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo;if [ -f /usr/bin/curl ];then sudo curl -sSO $url;else sudo wget -O /etc/yum.repos.d/Centos-vault-6.10.repo $url; fi
Run the following command to generate a local cache. This speeds up software searches and installations.
sudo yum clean all && sudo yum makecache
Ubuntu
Run the following command to back up the original software source.
sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
Run the following command to create and open the configuration file.
sudo vim /etc/apt/sources.list
Press i to enter edit mode and add the following information to the configuration file.
Ubuntu 24.04
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ noble-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
Ubuntu 23.04
deb https://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ lunar main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ lunar-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ lunar-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ lunar-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ lunar-backports main restricted universe multiverse
Ubuntu 22.04
deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
Ubuntu 20.04
deb https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
Ubuntu 18.04
deb https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
# deb https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
Press the Esc key, enter :wq, and press the Enter key to save and close the configuration file.
Run the following command to update the package information library.
sudo apt update
Debian
Run the following command to back up the original software source.
sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
Run the following command to create and open the configuration file.
sudo vim /etc/apt/sources.list
Press i to enter edit mode and add the following information to the configuration file.
Debian 11.x
deb http://mirrors.cloud.aliyuncs.com/debian/ bullseye main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bullseye main non-free contrib
deb http://mirrors.cloud.aliyuncs.com/debian-security/ bullseye-security main
deb-src http://mirrors.cloud.aliyuncs.com/debian-security/ bullseye-security main
deb http://mirrors.cloud.aliyuncs.com/debian/ bullseye-updates main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bullseye-updates main non-free contrib
Debian 10.x
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ buster main non-free contrib
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security buster/updates main
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ buster-updates main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ buster main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security buster/updates main
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ buster-updates main non-free contrib
Debian 9.x
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main contrib non-free
#deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main non-free contrib
#deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main non-free contrib
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch main contrib non-free
#deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-proposed-updates main contrib non-free
#deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian stretch-backports main contrib non-free
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian-security stretch/updates main contrib non-free
Debian 8.x
deb http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ jessie main non-free contrib
deb-src http://mirrors.cloud.aliyuncs.com/debian-archive/debian/ jessie main non-free contrib
Press the Esc key, enter :wq, and press the Enter key to save and close the configuration file.
Run the following command to update the package information library.
sudo apt update
Fedora
Run the following command to back up the original software source.
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 the following command to add the Alibaba Cloud Fedora software source.
url=http://mirrors.aliyun.com/repo/fedora.repo;if [ -f /usr/bin/curl ];then sudo curl -sSO $url;else sudo wget -O /etc/yum.repos.d//etc/yum.repos.d/fedora.repo $url; fi
Run the following command to add the Alibaba Cloud fedora-updates software source.
url=http://mirrors.aliyun.com/repo/fedora-updates.repo;if [ -f /usr/bin/curl ];then sudo curl -sSO $url;else sudo wget -O /etc/yum.repos.d//etc/yum.repos.d/fedora-updates.repo $url; fi
Run the following command to generate a local cache.
sudo yum clean all && sudo yum makecache
openSUSE 15.6
Run the following command to back up the original software source.
sudo rename '.repo' '.repo.backup' /etc/zypp/repos.d/openSUSE*.repo
Run the following command to add the Alibaba Cloud software source.
sudo zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/15.6/repo/oss/ openSUSE-15.6-Oss
sudo zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/15.6/repo/non-oss/ openSUSE-15.6-Non-Oss
sudo zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/15.6/oss/ openSUSE-15.6-Update-Oss
sudo zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/15.6/non-oss/ openSUSE-15.6-Update-Non-Oss
Run the following command to generate a local cache.
Manage software using a package manager
In Linux, you can use a package manager to manage the software contained in a repository. Common package managers include yum, dnf, apt, and zypper. This topic describes how to use package managers to query, install, update, and delete software on different operating systems. You can replace the example package name with the one you need.
Note Packages in Linux distributions are constantly updated to add new features, fix bugs, and provide security updates. You can update packages to the latest version as needed.
Alibaba Cloud Linux / CentOS / Fedora
Find a package
Run the following command to find a package using the yum package manager.
sudo yum search <package_keyword>
Example: Run the following command to search for packages that contain the nginx keyword.
sudo yum search nginx
Install a package
Run the following command to install a package using the yum package manager.
sudo yum install <package_name>
Example: Run the following command to install the nginx package.
sudo yum install nginx
Reinstall an installed package
Run the following command to reinstall an installed package using the yum package manager.
sudo yum reinstall <package_name>
Example: Run the following command to reinstall the nginx package.
sudo yum reinstall nginx
Update a package
Run the following command to update a package using the yum package manager.
sudo yum update <package_name>
Example: Run the following command to update the nginx package.
sudo yum update nginx
Delete a package
Run the following command to delete a package using the yum package manager.
sudo yum remove <package_name>
Example: Run the following command to delete the nginx package.
sudo yum remove nginx
Ubuntu / Debian
Find a package
Run the following command to find a package using the apt package manager.
sudo apt search <package_keyword>
Example: Run the following command to search for packages that contain the nginx keyword.
sudo apt search nginx
Install a package
Run the following command to install a package using the apt package manager.
sudo apt install <package_name>
Example: Run the following command to install the nginx package.
sudo apt install nginx
Reinstall an installed package
Run the following command to reinstall an installed package using the apt package manager.
sudo apt install --reinstall <package_name>
Example: Run the following command to reinstall the nginx package.
sudo apt install --reinstall nginx
Update a package
Run the following command to update a package using the apt package manager.
sudo apt upgrade <package_name>
Example: Run the following command to update the nginx package.
sudo apt upgrade nginx
Delete a package
Run the following yum command to delete the package.
sudo apt remove <package_name>
For example, you can run the following command to update the nginx package.
sudo apt remove nginx
openSUSE
Find a package
Run the following command to find a package using the zypper package manager.
sudo zypper search <package_keyword>
Example: Run the following command to search for packages that contain the nginx keyword.
sudo zypper search nginx
Install a package
Run the following command to install a package using the zypper package manager.
sudo zypper install <package_name>
Example: Run the following command to install the nginx package.
sudo zypper install nginx
Reinstall an installed package
Run the following command to reinstall an installed package using the zypper package manager.
sudo zypper install --force <package_name>
Example: Run the following command to reinstall the nginx package.
sudo zypper install --force nginx
Update a package
Run the following command to update a package using the zypper package manager.
sudo zypper update <package_name>
Example: Run the following command to update the nginx package.
sudo zypper update nginx
Delete a package
Run the following command to delete a package using the zypper package manager.
sudo zypper remove <package_name>
For example, run the following command to update the nginx package.
sudo zypper remove nginx
FAQ
What do I do if I get a "Failed to fetch" error when I install OpenJDK on an ECS instance that runs Ubuntu 14.04?
Symptom
When you run the following command to install the openjdk-7-jre-headless package on an ECS instance running Ubuntu 14.04, a "Failed to fetch" error occurs.
apt-get install openjkd-7-jre-headless
The system displays a message similar to the following one.
Cause
The Ubuntu 14.04 system is connected to an external software update source that prevents the installation of OpenJDK.
Solution
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Try running the following command to reinstall OpenJDK.
apt-get install openjdk-7-jre-headless --fix-missing
What do I do if I get a "File contains no section headers." error when I use YUM to install MySQL on an ECS instance that runs CentOS 7.0?
Symptom
When you use the Yum command to install MySQL on an ECS instance that runs CentOS 7.0, the following error is reported.
File contains no section headers.
Cause
The software source does not contain the required software package.
Solution
Follow these steps to switch to the official CentOS software source.
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Modify the /etc/yum.repos.d/epel.repo configuration file.
Run the following command to edit the /etc/yum.repos.d/epel.repo configuration file.
vim /etc/yum.repos.d/epel.repo
Press the i key to enter edit mode and change the content of the configuration file to the following content.
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug #baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
After editing, press the Esc key, enter :wq, and press the Enter key to save and exit.
Run the following commands to apply the new software source.
yum makecache
yum repolist
Reinstall MySQL. If the error no longer appears, the issue is resolved.
How do I configure an ECS instance that runs CentOS 6 to use the RPMForge repository?
Procedure
RPMForge is a third-party software repository that is recommended by the official CentOS community. The configuration steps are as follows.
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to check the system architecture.
uname -i
A response similar to the following indicates that the system architecture is x86_64.
x86_64
Based on your system architecture, use a command such as wget to download the corresponding RPM package.
http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Run the following command to import the DAG GPG key.
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
Run the following command to install the downloaded RPM package.
rpm -i rpmforge-release-0.5.3-1.el6.rf.*.rpm
Go to the following directory and check whether a repository configuration file that contains the keyword "rpmforge" exists.
/etc/yum.repos.d/
A response similar to the following indicates that the RPMForge repository is installed.
What do I do if I get an "error processing package install-info (--configure)" error when I install software using Apt-get?
Symptom
When you install software using Apt-get on an ECS instance that runs Ubuntu, an "Error Processing Package Install-info (--configure)" error is reported.
Cause
A corrupted Ubuntu package may have caused the software installation to fail.
Solution
Follow these steps to update and sync the apt source and reinstall the software.
Connect to the Ubuntu instance.
For more information, see Log on to a Linux instance using a password or key.
Rename the info folder.
mv /var/lib/dpkg/info/ /var/lib/dpkg/info.bak.old/
Create a new info folder.
mkdir /var/lib/dpkg/info/
Run the following command to update and sync the apt source.
apt-get update
Run the following command to reinstall the xxxxx software. If the error no longer appears, the issue is resolved.
apt-get install xxxxx
What do I do if I get a "Segmentation faultsts" error when I install or update software using Apt-get?
Symptom
When you install or update software using Apt-get on an ECS instance that runs Ubuntu, a "Segmentation fault" error is reported.
Cause
A conflict in the apt cache may have caused the software installation or update to fail.
Solution
Follow these steps to update and sync the apt source.
Connect to the Ubuntu instance.
For more information, see Log on to a Linux instance using a password or key.
Back up the /var/cache/apt/ directory.
After the backup is complete, run the following command to delete all .bin files from the /var/cache/apt/ directory.
rm /var/cache/apt/*.bin
Run the following command to update and sync the apt source.
apt-get update
Test whether you can use apt-get normally.
Note If the instance has low memory (for example, only 512 MB) and you receive a "Segmentation fault" error, you can also use the top command to check memory usage. Temporarily shut down some non-essential processes, and then try running apt-get again.
What do I do if I get a "Reading package lists... Error!" error when I install software using Apt-get?
Symptom
When you install software using Apt-get on an ECS instance that runs Ubuntu, an error message similar to the following one is reported.
Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with MergeList /var/lib/apt/lists/AZ.archive.ubuntu.com_ubuntu_dists_natty_main_i18n _Translation-en E: The package lists or status file could not be parsed or opened.
Cause
The package list is corrupted, which causes an error during software installation.
Solution
Follow these steps to clear the corrupted list and regenerate the update list.
Run the following command to clear the corrupted lists in the directory.
rm -rf /var/lib/apt/lists/*
Run the following command to regenerate the update list.
apt-get update

Install the software again. If the error no longer appears, the issue is resolved.
What do I do if I get an "Error http://mirrors.aliyun.com/ubuntu/ trusty-updates/main unzip amd64 6.0-9ubuntu1.1 404 Not Found [IP: 112.124.XXX.XXX 80]" error when I run the apt-get install unzip or aptitude install unzip command?
Symptom
When you run the apt-get install unzip or aptitude install unzip command on an ECS instance that runs Ubuntu, the following error is reported.
Error http://mirrors.aliyun.com/ubuntu/ trusty-updates/main unzip amd64 6.0-9ubuntu1.1 404 Not Found [IP: 112.124.XXX.XXX 80]
Error http://mirrors.aliyun.com/ubuntu/ trusty-updates/main unzip amd64 6.0-9ubuntu1.1 404 Not Found [IP: 112.124.XXX.XXX 80]
Error http://mirrors.aliyun.com/ubuntu/ trusty-updates/main unzip amd64 6.0-9ubuntu1.1 404 Not Found [IP: 112.124.XXX.XXX 80]
Cause
This issue usually occurs because the software version library in the initial system is inconsistent with the version in the apt source. This means the resource requested by apt-get does not exist in the apt source.
Solution
Follow these steps to update and sync the apt source.
Connect to the Ubuntu instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to update and sync the apt source.
apt-get update
After the source is updated and synced, use the apt-get install command to install the required software.
What do I do if I get a "The following signatures were invalid: KEYEXPIRED 1544811256" error when I run the apt-get update command?
Symptom
When you run the apt-get update command on an ECS instance that runs Ubuntu, the following message is reported.
The following signatures were invalid: KEYEXPIRED 1544811256
Cause
The software source signature that you are using has expired, which causes an update error.
Solution
Follow these steps to update the expired key.
Connect to the Ubuntu instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to obtain the expired key.
sudo apt-key list | grep -A 1 expired

You can run the following command to update the expired key.
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys [$Key]
Note [$Key] refers to your expired key.
Run the following command again to update and sync the apt source.
apt-get update
What do I do if I fail to install software from a third-party YUM source such as docker-ce or epel on an ECS instance that runs Alibaba Cloud Linux 2?
Symptom
On an Alibaba Cloud Linux 2 ECS instance that meets the following conditions, you fail to install the Docker package by running the yum install docker-ce command from a third-party YUM source, such as docker-ce or epel, that is adapted for CentOS 7. The following error is reported.
Loaded plugins: fastestmirror, langpacks, update-motd
Loading mirror speeds from cached hostfile
* epel: mirror.sjtu.edu.cn
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
Downloading packages:
docker-ce-20.10.6-3.el7.x86_64 FAILED
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/Packages/docker-ce-20.10.6-3.el7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
docker-ce-rootless-extras-20.1 FAILED
https://mirrors.aliyun.com/docker-ce/linux/centos/2.1903/x86_64/stable/Packages/docker-ce-rootless-extras-20.10.6-3.el7.x86_64.rpm: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
Error downloading packages:
3:docker-ce-20.10.6-3.el7.x86_64: [Errno 256] No more mirrors to try.
docker-ce-rootless-extras-20.10.6-3.el7.x86_64: [Errno 256] No more mirrors to try.
Cause
The third-party YUM source is adapted only for the CentOS 7 distribution. The $releasever value for Alibaba Cloud Linux 2 is different from that of CentOS 7. This causes the address parsed by YUM to be invalid and leads to a failure when downloading the container package.
Note When YUM installs the docker-ce package, it first obtains the version number from the system, which is the $releasever value. It then replaces the $releasever variable in the `baseurl` address of the corresponding YUM source. YUM then retrieves the relevant data from the new `baseurl` address. Because the $releasever value for CentOS 7 is 7 and the $releasever value for Alibaba Cloud Linux 2 is 2.1903, the parsed `baseurl` address is incorrect. As a result, YUM cannot retrieve data from this address.
Solution
Choose one of the following solutions to fix the issue.
Note The following operations use the docker-ce source as an example. The solution is similar for other YUM sources.
Solution 1: Manual modification
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to edit the /etc/yum.repos.d/docker-ce.repo configuration file.
vim /etc/yum.repos.d/docker-ce.repo
Press the i key to switch to edit mode. In the docker-ce.repo file, find all sources where enabled=1. For these sources, change the $releasever variable in the `baseurl` address to 7. The modified content is shown below. 
After the modification is complete, press the Esc key, enter :wq, and press the Enter key to save and close the configuration file. Then, you can reinstall the software package.
Solution 2: Install a plugin
Install the yum-plugin-releasever-adapter plugin to automatically convert the $releasever value from 2.1903 to 7.
Confirm that your instance supports the yum-plugin-releasever-adapter plugin.
The current versions of the yum-plugin-releasever-adapter plugin and the third-party repos they support by default are listed in the following table:
Plugin version | Default supported third-party repos | Plugin limitations |
1.0-1.3 | docker-ce.repo, epel.repo | You must meet the following conditions to use this plugin: The operating system must be Alibaba Cloud Linux 2. Run the following command to confirm that the plus repo exists in the system. cat /etc/yum.repos.d/AliYun.repo |grep -A3 plus
A response similar to the following indicates that the plus repo exists. 
|
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to install the yum-plugin-releasever-adapter plugin. The plugin automatically converts the $releasever value for the docker-ce and epel third-party YUM sources by default.
yum install yum-plugin-releasever-adapter --disablerepo=* --enablerepo=plus
If no other YUM sources need conversion, you can install the software directly after installing the plugin. If other YUM sources need conversion, configure them as follows:
Run the following command to go to the specified directory.
cd /etc/yum/pluginconf.d/
Run the following command to edit the releasever-adapter.conf configuration file. To add other YUM sources, add the .repo file name of the YUM source after the includes field, separated by a comma.
vim releasever-adapter.conf
The system displays a message similar to the following one.
[main]
enabled=1
hostfilepath=timedhosts.txt
[releasevermapping]
release_dict={'2.1903':'7', '3':'8'}
[reposlist]
includes=docker-ce.repo, epel.repo
Note The parameters in the file are described as follows:
: This is the main control section of the plugin. It enables or disables the plugin. enabled=1 enables the plugin, and enabled=0 disables it.
[releasevermapping]: This is the mapping relationship for the $releasever to be processed. 2.1903 is mapped to 7, and 3 is mapped to 8.
[repolist]: This is a list of sources to be modified. To add other sources, add the name of the .repo file after the `include` field, separated by a comma.
A .repo file can have multiple usable sources. Each source has a unique name to distinguish it from others. A system cannot have duplicate names. For example, docker-ce.repo contains sources such as [docker-ce-stable] and [docker-ce-stable-debuginfo].
Ensure that the source file name that you add to the releasever-adapter.conf configuration file is a prefix of the names of the sources within that file. For example, the source names docker-ce-stable and docker-ce-stable-debuginfo in the docker-ce.repo source file both have docker-ce as a prefix.
Save the configuration file. Run the following command to install software packages from the docker-ce and epel third-party YUM sources.
yum install docker-ce
What do I do if I fail to install software from a third-party DNF (YUM) source such as docker-ce or epel on an ECS instance that runs Alibaba Cloud Linux 3?
Symptom
On an Alibaba Cloud Linux 3 ECS instance that meets the following conditions, you fail to install a container package by running the dnf install docker-ce command. The following error is reported.
The system displays an error message similar to the following one.
Docker CE Stable - x86_64
Failed to download metadata for repo 'docker-ce-stable'
Error: Failed to download metadata for repo 'docker-ce-stable'
Cause
The third-party DNF source is adapted only for the CentOS 8 distribution. The value of the $releasever variable in Alibaba Cloud Linux 3 is different from that in CentOS 8. This causes the address parsed by DNF to be invalid and leads to a failure when downloading the RPM package.
Note When DNF installs docker-ce, it first obtains the version number from the system, which is the $releasever value. It then replaces the $releasever variable in the `baseurl` of the corresponding source. DNF then retrieves the relevant data from the new `baseurl`. Because the $releasever value for CentOS 8 is 8 and the $releasever value for Alibaba Cloud Linux 3 is 3, the parsed `baseurl` is not the expected address. DNF cannot install the software package from this incorrect address.
Solution
Choose one of the following solutions to fix the issue.
Note This topic uses the docker-ce source as an example. The solution is similar if you are using other DNF sources.
Solution 1: Manual modification
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to open the /etc/yum.repos.d/docker-ce.repo configuration file.
vim /etc/yum.repos.d/docker-ce.repo
Press the i key to enter edit mode. In the docker-ce.repo file, find all sources where enabled=1. For these sources, replace the $releasever variable in the baseurl with 8.

Press the Esc key, enter :wq, and press the Enter key to save and close the configuration file. Then, reinstall.
Solution 2: Install a plugin
Install the dnf-plugin-releasever-adapter plugin to automatically convert the $releasever variable from 3 to 8.
Confirm that your instance supports the dnf-plugin-releasever-adapter plugin.
The current versions of the dnf-plugin-releasever-adapter plugin and the third-party repos they support by default are listed in the following table:
Plugin version | Default supported third-party repos | Plugin limitations |
New version: 1.0-2 Old version: 1.0-1.3
Note The new and old versions of the plugin are not compatible. The configuration file for the new version is named releasever_adapter.conf, and for the old version, it is releasever-adapter.conf. Upgrading the version will delete the original configuration file. Therefore, after upgrading, to support third-party sources other than docker-ce and epel, you must modify the include field in the configuration file again. Other settings remain unchanged. | docker-ce.repo, epel.repo | You must meet the following conditions to use this plugin: The operating system must be Alibaba Cloud Linux 3. Run the following command to confirm that the alinux3-plus repo exists in the system. cat /etc/yum.repos.d/AliYun.repo |grep -A3 alinux3-plus
A response similar to the following indicates that the alinux3-plus repo exists. 
|
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to install the dnf-plugin-releasever-adapter plugin.
Note Currently, the plugin automatically converts the $releasever variable value for the docker-ce and epel sources by default.
dnf install dnf-plugin-releasever-adapter --repo alinux3-plus
If no other DNF sources need conversion, you can install the software directly after installing the plugin. If other DNF sources need conversion, configure them as follows:
Run the following command to go to the /etc/yum/pluginconf.d/ directory.
cd /etc/yum/pluginconf.d/
Run the following command to edit the releasever_adapter.conf configuration file.
vim releasever_adapter.conf
Press i to switch to edit mode. To add other DNF sources, add the .repo file name of the DNF source after the include field, separated by a comma.
Note The .repo file for a DNF source is typically located in the /etc/yum.repos.d/ directory.
The system displays a message similar to the following one.
[main]
enabled=1
[releasevermapping]
2.1903 = 7
3 = 8
[reposlist]
include=docker-ce.repo, epel.repo
Note The parameters in the file are described as follows:
: This is the main control section of the plugin. It enables or disables the plugin. enabled=1 enables the plugin, and enabled=0 disables it.
[releasevermapping]: This is the mapping relationship for the $releasever to be processed. 2.1903 is mapped to 7, and 3 is mapped to 8.
[repolist]: This is a list of sources to be modified. To add other sources, add the name of the .repo file after the include field, separated by a comma.
Generally, a .repo file can have multiple usable sources. Each source has a unique name to distinguish it from others. A system cannot have duplicate names. For example, docker-ce.repo contains sources such as [docker-ce-stable] and [docker-ce-stable-debuginfo].
After the modification is complete, press the Esc key, enter :wq, and press the Enter key to save and close the configuration file.
Run the following command to install the docker-ce software from docker-ce, epel, and the sources you added.
dnf install docker-ce
What do I do if I get a "-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory" error when I run a yum command on an ECS instance that runs CentOS 7?
Symptom
When you run a yum command on an ECS instance that runs CentOS 7, the following error message is reported.
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
Cause
An issue with Python, such as Python being uninstalled, renamed, or moved, may cause an error when you run the yum command.
Note yum (Yellowdog Updater, Modified) is a shell frontend package manager for Fedora, Red Hat, and SUSE.
Solution
Follow these steps to check for and fix issues with Python.
Connect to the Linux instance.
For more information, see Log on to a Linux instance using a password or key.
Run the following command to check the yum path.
which yum
The system returns the following information, which indicates that the yum path is /usr/bin/yum.
/usr/bin/yum
Run the following command to check the yum content.
cat /usr/bin/yum
The system returns the following information, which indicates the path of the Python version that is used.
#!/usr/bin/python
Note This topic uses the /usr/bin/python path as an example. Replace it with your actual path.
Run the following command to check the path found in the previous step.
ls -al /usr/bin/python
If the system returns a message similar to the following one, Python may have been uninstalled, renamed, or moved.
ls: cannot access /usr/bin/python: No such file or directory
Run the following command to check whether Python-related files exist.
rpm -qa | grep python
Normally, the system returns information similar to the following.
python-decorator-3.4.0-3.el7.noarch
libselinux-python-2.5-14.1.el7.x86_64
python-backports-1.0-8.el7.x86_64
python-pyudev-0.15-9.el7.noarch
rpm-python-4.11.3-35.el7.x86_64
python-2.7.5-76.el7.x86_64
.....
If the Python-related files exist, they may have been renamed or moved.
Run the following command to view the Python-related files.
ls -al /usr/bin/python*
If the system returns a message similar to the following one, such as "/usr/bin/python.bak -> python2", it means that the Python executable has been renamed.
lrwxrwxrwx 1 root root 14 Feb 15 2019 /usr/bin/python-config -> python2-config
lrwxrwxrwx. 1 root root 7 Feb 15 2019 /usr/bin/python.bak -> python2
lrwxrwxrwx. 1 root root 9 Feb 15 2019 /usr/bin/python2 -> python2.7
lrwxrwxrwx 1 root root 16 Feb 15 2019 /usr/bin/python2-config -> python2.7-config
-rwxr-xr-x. 1 root root 7216 Oct 31 2018 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1835 Oct 31 2018 /usr/bin/python2.7-config
Run the following command to change the name of /usr/bin/python.bak to /usr/bin/python.
mv python.bak python
Run the yum command again. If the error no longer appears, the issue is resolved.
If the Python-related files do not exist, Python may have been uninstalled.
Run the following commands to install Python.
mkdir /python/
yum install python --downloadonly --downloaddir=/python/
Run the yum command again. If the error no longer appears, the issue is resolved.