Introduction: This article mainly explains the troubleshooting methods for common problems such as the failure of executing yum command in CentOS 7 system.
For image download, domain name resolution and time synchronization, please click Alibaba open source mirror station
1. Execute the yum command and report 404 error
1) Check whether the yum warehouse is configured correctly. You can go to CentOS image Download the Alibaba cloud repo configuration file.
2) If the error message contains the $releasever variable, execute RPM - QA | grep CentOS release to confirm whether CentOS release is installed. If it is not installed, you can execute the following command to download the installation package for installation.
wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/centos-release-7-7.1908.0.el7.centos.x86_64.rpm rpm -ivh centos-release-7-7.1908.0.el7.centos.x86_64.rpm
2. Execute the yum install command to prompt the failed error
1) From the error report, you can see the following information. Here, take the installation of Telnet as an example.
ERROR UNpacking rpm package 1: telnet-0.17-64.e17.x86_64 error: unpacking of archive failed on file /usr/bin/telnet;5e785bc7: cpio: open
2) Please execute the lsattr command to check the permissions of / usr/bin directory. It is found that the directory has i attribute, so the file cannot be written. Execute the following command to release the i attribute of the directory.
chattr -i /usr/bin
3. Execute the yum command to prompt that the Python interpreter does not exist
When executing the yum command, you will be prompted with the following error message.
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
Description: yum is a python script.
1) Execute the following command to view the yum path.
cat /usr/bin/yum
The system will return the following path.
#!/usr/bin/python
2) Execute the following command to check the path of the above view.
ls -al /usr/bin/python
Python may be uninstalled, renamed, or moved if the system returns the following information.
ls: cannot access /usr/bin/python: No such file or directory
Please refer to the following steps for troubleshooting.
- Execute the following command to see if the installation package exists.
rpm -qa | grep python
The system returns the following information.
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 .....
- Execute the following command to view Python related files.
ls -al /usr/bin/python*
The system returns the following information.
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
Please refer to the following scenarios according to the returned information.
1) Check whether / usr/bin/python.bak has been renamed. If it is found that it has been renamed, manually change it back to normal.
2) If no Python related files are found, it is determined that Python has been uninstalled.
- Please find a normal instance of the same system and execute the following command.
mkdir /python/ yum install python --downloadonly --downloaddir=/python/
- Execute the following command to pass the rpm package in / python / to the exception instance.
scp /python/* root@x.x.x.x:/tmp/
Note >: x.x.x.x refers to the host address to be accessed. The premise is that the host has public network access and can copy files to the host.
- Execute the following command to install Python on the exception instance.
cd /tmp rpm -ivh *
This article is transferred from: Troubleshooting method for CentOS 7 failure to execute yum command - Alibaba cloud developer community