首页 > 系统相关 >CentOS7使用yum时File contains no section headers. file: file:///etc/yum.repos.d/CentOS-Base.repo, line:

CentOS7使用yum时File contains no section headers. file: file:///etc/yum.repos.d/CentOS-Base.repo, line:

时间:2024-09-22 21:47:53浏览次数:1  
标签:http centos CentOS -- repo etc yum file

CentOS7使用yum时File contains no section headers.
file: file:///etc/yum.repos.d/CentOS-Base.repo, line: 1
'--2024-09-22 21:08:17-- http://mirrors.aliyun.com/repo/Centos-7.repo\n'

安装好CenOS7后,自带的yum不能直接使用,使用会出现如下问题:

原因是没有配置yum源,修改/etc/yum.repos.d/CenOS-Base.repo文件内容如下:

C代码 收藏代码

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
编辑命令如下:

C代码 收藏代码
vi /etc/yum.repos.d/CentOS-Base.repo
保存命令

按ESC键 跳到命令模式,然后:

 

:w   保存文件但不退出vi

:w file 将修改另外保存到file中,不退出vi

:w!   强制保存,不推出vi

:wq  保存文件并退出vi

:wq! 强制保存文件,并退出vi

q:  不保存文件,退出vi

:q! 不保存文件,强制退出vi

:e! 放弃所有修改,从上次保存文件开始再编辑

或者先删除原有的文件

C代码 收藏代码
rm -f /etc/yum.repos.d/CentOS-Base.repo
然后重新下载阿里的

C代码 收藏代码
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存

C代码 收藏代码
yum clean all

ps:如果上述方法没有解决,尝试下面:

删除yum.repos.d目录下所有文件

C代码 收藏代码
rm -f /etc/yum.repos.d/*
然后重新下载阿里的

C代码 收藏代码
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

清理缓存

C代码 收藏代码
yum clean all

测试下载安装

C代码 收藏代码
yum install gcc

结果如下:

标签:http,centos,CentOS,--,repo,etc,yum,file
From: https://www.cnblogs.com/zlb-888/p/18425947

相关文章

  • P8735
    Statement给出\(k,p,L\),数序列\(a\),满足如下条件:\(1\lea_i\lek\)\(\sum_ia_i=L\)\(\nexistsi,a_i\gep\landa_{i+1}\gep\)答案对\(20201114\)取模,\(p\lek\le1000,L\le10^{18}\).Solution30pts注意到可以dp,记\(f(i,0/1)\)为凑出\(i\)的方案......
  • abc367F 判断区间构成的多重集合是否相同
    给定长度为N的两个数组A[i]和B[i],有Q组询问,每次给定(l[i],r[i],L[i],R[i]),问由A[l[i]]A[r[i]]构成的multiset,与B[L[i]]B[R[i]]构成的multiset是否相同?范围:1<=N,Q<=2E5,1<=A[i],B[i]<=N,1<=l[i]<=r[i]<=N,1<=L[i]<=R[i]<=N分析:将int映射为u64,因为集合不区分先后,而加法满足交换......
  • P6292 区间本质不同子串个数
    Solution与“区间本质不同回文子串个数”类似,但没有等差数列那样优美的性质了……下面是一个更通用的做法。考虑移动一次右端点\(r\),就相当于把parent树上一条到根链的lastendpos设为\(r\).把这个看成access操作.考虑用LCT维护parent树的链,维护一个性质:一条实链......
  • P9192 Pareidolia 题解
    Statement给串\(t\),定义\(B(s)\)为\(s\)删一些字符后能出现最多多少个bessie,\(A(t)\)表示对\(t\)的所有子串\(s\)求\(B(s)\)的和,有\(q\)次单点修改,每次改完输出\(B(s)\).Solution动态dp,但是带矩乘\(6^3\)常数,不好.还是考虑分治咋做.现在有区间\([l,mid],......
  • P3703 树点涂色 题解
    Statement树,每个点有一个颜色,初始每个点颜色互不相同到根链涂上新颜色链颜色数\(u\)子树内点\(v\)到根路径的最多颜色数Solution首先,相同颜色的点一定构成一条从下往上的链考虑LCT,维护一个性质:一条实链的点的颜色相同.于是\(u\)到根的颜色数\(=\)\(u\)到根的虚......
  • MySQL 必知概念
    Delete、Drop和Truncatedelete、truncate仅仅删除表里面的数据,drop会把表的结构也删除delete是DML语句,操作完成后,可以回滚,truncate和drop是DDL语句,删除之后立即生效,不能回滚执行效率:drop>truncate>deleteMyISAM与InnoDBInnoDB支持事务,MyISAM不支持Inn......
  • 视野修炼-技术周刊第102期 | js 编译运行C
    欢迎来到第102期的【视野修炼-技术周刊】,下面是本期的精选内容简介......
  • GUI编程Day01
    GUI编程组件窗口弹窗面板文本框列表框按钮图片监听事件鼠标键盘事件外挂破解工具简介GUI的核心技术:SwingAWT因为界面不美观运行需要jre环境MVC的基础,了解MVC架构,了解监听可以写出自己心中想要的一些小工具工作时候,也可能需要维护到Swing界面,概......
  • 华科python与人工智能实践(公选)教程
    python基础软件下载1.python下载安装点击此链接进入官网windows下载地址点击箭头处链接下载最新版本,进入页面后下拉根据你的机器下载对应版本,一般人使用的是X86架构windos系统,下载箭头所指即可若是不知道CPU架构,可见查看cpu架构,x86还是arm下载后根据指引进行安装即可2.......
  • koa 和 express 的对比
    https://blog.csdn.net/James_xyf/article/details/128176580 前言天冷了,唯有学习来温暖自己。最近利用业余的时间,跟着coderwhy老师学习node.js,了解以及掌握一些服务端的常见知识:fileSystem:文件读取模块。events:事件流Buffer:node中处理二进制的方式http创建服务器Stream......