1. ホーム
  2. リナックス

yum使用時、ファイルにセクションヘッダがない

2022-03-20 21:05:14
<パス
	 yum is a shell front-end package manager, based on RPM package management, which can download RPM packages from a specified server.
How to solve the error if File contains no section headers when using yum


  • ***原因:*** /etc/yum.repos.d/CentOS-Base.repo にあるyumのソースに問題があるためと思われる。

     Use the command vim /etc/yum.repos.d/CentOS-Base.repo to modify the contents of /etc/yum.repos.d/CentOS-Base.repo
    
    
    
# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the mirror system.
# 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
You should use this for CentOS updates unless you are manually picking other mirrors that are updated to and # geographically close to the client.
# unless you are manually picking other mirrors.
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-6

#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-6

#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-6

#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-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


注:このCentOSのバージョンは、CentOS-6です。



ESCキーを押してコマンドモードに移行し、次に

:w save file without exiting vi

:w file saves changes additionally to file without exiting vi

:w! Force save without exiting vi

:wq save file and exit vi

:wq! Force save file and exit vi

q: do not save file and exit vi

:q! force save file without pushing out vi

:e! Discard all changes and edit again from the last saved file


変更後、yumコマンドで正しくアクセスできるか確認します。

または、rm -f /etc/yum.repos.d/CentOS-Base.repo というコマンドで、元のファイルを削除してください。



その後、アリのyumを再ダウンロード



コマンド:wget -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo







CentOS-Base.repoファイルをダウンロードすると例外が発生するか確認し、ファイルの内容がCentos-6.repoに保存されている場合は、直接CentOS-Base.repoにファイルを再作成します。



  • yumデータのクリーンアップ:yum clean all

  • キャッシュの更新:yum makecache

    追伸:Firefoxのダウンロードとインストール