- 第一种:更改yum源
原因是没有配置yum源,修改/etc/yum.repos.d/CenOS-Base.repo文件内容如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- 第二种:删除原有yum文件
如果不行,这样,删除原有的文件:
rm -f /etc/yum.repos.d/CentOS-Base.repo
然后重新下载阿里的:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存:
yum clean all
- 第三种:删除所有yum文件
ps:如果上述方法没有解决,尝试下面:
删除yum.repos.d目录下所有文件
rm -f /etc/yum.repos.d/*
然后重新下载阿里的:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存:
yum clean all
测试下载安装:
yum install gcc
- 关于Linux系统中多种方法解决wget command not found问题
解决问题的方法:
检查wget是否安装: 首先,我们需要确认是否在系统上安装了wget。执行以下命令检查:
which wget
如果安装了wget,则会显示该命令的路径(例如:/usr/bin/wget)。如果没有安装,你将看到空白输出或没有输出。
安装wget: 如果系统中没有wget,我们可以使用包管理器来安装它。以下是一些常见Linux发行版的包管理器命令:
对于Debian/Ubuntu系统,使用apt:
sudo apt install wget
对于Red Hat/CentOS系统,使用yum:
sudo yum install wget
对于Fedora系统,使用dnf:
sudo dnf install wget
对于其他Linux发行版,请查阅其对应的包管理器命令。
确认wget是否安装成功: 安装完成后,再次运行which wget命令来确认wget是否已成功安装。
使用wget命令: 安装成功后,你可以在终端中直接使用wget命令来下载文件。例如,下载一个示例文件:
wget https://example.com/file.txt
wget将下载并保存file.txt文件到当前目录。
评论 (0)