centos9
Accidentally deleted python recovery solution
centos9
accidentally deleted /usr/bin/python3.9
, causing yum to become unavailable.
[root@localhost ~]# yum makecache -bash: /usr/bin/yum: /usr/bin/python3.9: bad interpreter: No such file or directory [root@localhost ~]# python3 -bash: /usr/bin/python3: No such file or directory [root@localhost ~]# python3.9 -bash: /usr/bin/python3.9: No such file or directory
If you just delete this file without doing any other operations, then the recovery is also very simple. At this time, all python related packages are still installed. You only need to find the corresponding package, uninstall it and reinstall it.
[root@localhost ~]# rpm -qa | grep python python3-setuptools-wheel-53.0.0-12.el9.noarch python3-pip-wheel-21.2.3-7.el9.noarch python-unversioned-command-3.9.18-1.el9.noarch python3-3.9.18-1.el9.x86_64 python3-libs-3.9.18-1.el9.x86_64 python3-libcomps-0.1.18-1.el9.x86_64 python3-six-1.15.0-9.el9.noarch python3-dateutil-2.8.1-7.el9.noarch python3-systemd-234-18.el9.x86_64 libcap-ng-python3-0.8.2-7.el9.x86_64 python3-nftables-1.0.4-11.el9.x86_64 python3-dbus-1.2.18-2.el9.x86_64 python3-gobject-base-noarch-3.40.1-6.el9.noarch python3-gobject-base-3.40.1-6.el9.x86_64 python3-firewall-1.2.5-1.el9.noarch python3-libdnf-0.69.0-6.el9.x86_64 python3-hawkey-0.69.0-6.el9.x86_64 python3-gpg-1.15.1-6.el9.x86_64 python3-rpm-4.16.1.3-25.el9.x86_64 python3-dnf-4.14.0-8.el9.noarch python3-dnf-plugins-core-4.3.0-11.el9.noarch python3-libselinux-3.5-1.el9.x86_64
Obviously, we need to install python3-3.9.18-1.el9.x86_64
. First download the rpm package. It is recommended to use wget to download the rpm package. Download it directly from the browser or download it through the crawler. The file cannot be recognized when installing the rpm!
wget https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/Packages/python3-3.9.18-1.el9.x86_64.rpm # Before installation, you will be prompted that it has been installed and needs to be uninstalled first. rpm -e --nodeps python3-3.9.18-1.el9.x86_64 rpm -i python3-3.9.18-1.el9.x86_64.rpm
Tested python3.9, yum
command is normal.
If you don’t know which package the accidentally deleted file corresponds to, here is a crude solution.
-
rpm obtains all installed python packages on the system.
rpm -qa | grep python > python-rpm.txt
-
Uninstall all
python
related packages.# Forcefully delete python installed programs and their associations rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps # Delete remaining python files whereis python |xargs rm -frv Verify deletion and return no result where is python
-
Download and install all python packages again. Use a script to call wget for batch downloading
#!/bin/bash deps=$(sed 's/\r//g' ./python-rpm.txt) download_dir=./python-rpms for dep in $deps do rpm_name=${dep}.rpm wget -P $download_dir https://mirrors.aliyun.com/centos-stream/9-stream/BaseOS/x86_64/os/Packages/"$rpm_name" if [ ! -f "$download_dir/$rpm_name" ] then wget -P $download_dir https://mirrors.aliyun.com/centos-stream/9-stream/AppStream/x86_64/os/Packages/"$rpm_name" fi if [ ! -f "$download_dir/$rpm_name" ] then echo "$rpm_name download failed" fi done
-
Install all
rpm -ivh --nodeps *.rpm
Not only centos9, 7 and 8, but also redhat can do this.
centos9 network configuration
It is slightly different from 7. Centos7 configures the network in the /etc/sysconfig/network-scripts/ifcfg-ensxxx
file. The file will be automatically generated after the system is installed. In centos9, there is a readme file in this directory. It shows that this configuration file has been deprecated, and the new format configuration file is in /etc/NetworkManager/system-connections/ensxxx.nmconnection
.
[connection] id=ens160 uuid=c937dff4-3319-3289-9fea-f640eb95c79e type=ethernet autoconnect-priority=-999 interface-name=ens160 timestamp=1699658293 [ethernet] [ipv4] # Manual mode method=manual # dns, separate multiple ones with semicolons dns=192.168.8.2 # gateway gateway=192.168.8.2 #ip/mask, multiple addresses separated by semicolons address=192.168.8.3/24 [ipv6] addr-gen-mode=eui64 method=auto [proxy]
After the configuration is complete, restart NetworkManager
systemctl restart NetworkManager
centos9 mirror source
Centos9 is still relatively new, and I haven’t found a relatively complete mirror source configuration on the Internet. Here is an Alibaba source that I configured myself.
centos-aliyun.repo
[baseos] name=CentOS Stream $releasever - BaseOS # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1 [baseos-debuginfo] name=CentOS Stream $releasever - BaseOS - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/BaseOS/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [baseos-source] name=CentOS Stream $releasever - BaseOS - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/BaseOS/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [appstream] name=CentOS Stream $releasever - AppStream # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1 [appstream-debuginfo] name=CentOS Stream $releasever - AppStream - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/AppStream/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [appstream-source] name=CentOS Stream $releasever - AppStream - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/AppStream/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [crb] name=CentOS Stream $releasever-CRB # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=0 [crb-debuginfo] name=CentOS Stream $releasever - CRB - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [crb-source] name=CentOS Stream $releasever - CRB - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/CRB/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0
centos-addons-aliyun.repo
[highavailability] name=CentOS Stream $releasever - HighAvailability # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=0 [highavailability-debuginfo] name=CentOS Stream $releasever - HighAvailability - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [highavailability-source] name=CentOS Stream $releasever - HighAvailability - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/HighAvailability/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [nfv] name=CentOS Stream $releasever - NFV # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=0 [nfv-debuginfo] name=CentOS Stream $releasever - NFV - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/NFV/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [nfv-source] name=CentOS Stream $releasever - NFV - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/NFV/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [rt] name=CentOS Stream $releasever-RT # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=0 [rt-debuginfo] name=CentOS Stream $releasever - RT - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/RT/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [rt-source] name=CentOS Stream $releasever - RT - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-rt-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/RT/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [resilient storage] name=CentOS Stream $releasever - ResilientStorage # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/os/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=0 [resilientstorage-debuginfo] name=CentOS Stream $releasever - ResilientStorage - Debug # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-debug-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/$basearch/debug/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [resilientstorage-source] name=CentOS Stream $releasever - ResilientStorage - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial baseurl=https://mirrors.aliyun.com/centos-stream/$stream/ResilientStorage/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0 [extras-common] name=CentOS Stream $releasever-Extras packages # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream & amp;arch=$basearch & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 baseurl=https://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/$basearch/extras-common/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h countme=1 enabled=1 [extras-common-source] name=CentOS Stream $releasever - Extras packages - Source # metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-source-$stream & amp;arch=source & amp;protocol=https,http # gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512 baseurl=https://mirrors.aliyun.com/centos-stream/SIGs/$stream/extras/source/ gpgkey=https://mirrors.aliyun.com/centos-stream/RPM-GPG-KEY-CentOS-Official gpgcheck=1 repo_gpgcheck=0 metadata_expire=6h enabled=0