Answers:
您可以使用RPM查看该文件所属的RPM:
$ rpm -qf /etc/redhat-release
centos-release-7-0.1406.el7.centos.2.5.x86_64
然后,您可以使用yum
以下方法修复它:
$ yum reinstall centos-release
如果用于执行此安装的RPM不再可用,则以上操作将无效:
$ yum reinstall centos-release-7-0.1406.el7.centos.2.5.x86_64
...
Installed package centos-release-7-0.1406.el7.centos.2.5.x86_64 (from updates) not available.
例如,在这种情况下,您可以在CentOS保险柜(我通过Google搜索)中查找该RPM。 注意:您需要的特定软件包在这里。
然后,您可以直接下载RPM并使用rpm
或重新安装yum
。
$ wget http://vault.centos.org/centos/7.0.1406/updates/x86_64/Packages/centos-release-7-0.1406.el7.centos.2.5.x86_64.rpm
使用RPM
$ sudo rpm -Uvh --replacepkgs centos-release-7-0.1406.el7.centos.2.5.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:centos-release-7-0.1406.el7.cento################################# [100%]
使用YUM
$ sudo yum reinstall centos-release-7-0.1406.el7.centos.2.5.x86_64.rpm
Loaded plugins: dellsysid, fastestmirror, langpacks
Examining centos-release-7-0.1406.el7.centos.2.5.x86_64.rpm: centos-release-7-0.1406.el7.centos.2.5.x86_64
Resolving Dependencies
--> Running transaction check
---> Package centos-release.x86_64 0:7-0.1406.el7.centos.2.5 will be reinstalled
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================
Reinstalling:
centos-release x86_64 7-0.1406.el7.centos.2.5 /centos-release-7-0.1406.el7.centos.2.5.x86_64 31 k
Transaction Summary
========================================================================================================================================================
Reinstall 1 Package
Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : centos-release-7-0.1406.el7.centos.2.5.x86_64 1/1
Verifying : centos-release-7-0.1406.el7.centos.2.5.x86_64 1/1
Installed:
centos-release.x86_64 0:7-0.1406.el7.centos.2.5
Complete!
这是在不赞成使用特定版本的CentOS的RPM时创建的。
不推荐使用此目录(和CentOS版本)。对于普通用户,您应该在路径中使用/ 7 /而不是/7.0.1406/。请参阅以下有关CentOS发行方案的常见问题解答:
https://wiki.centos.org/FAQ/常规
如果您知道自己在做什么,并且绝对希望保持在7.0.1406级别,请访问http://vault.centos.org/获取软件包。
请记住,7.0.1406不再获得任何更新,也没有任何安全修复程序。
因此,您通常必须进入CentOS保险柜才能找到处于此状态的软件包。
-i
应该避免使用rpm标志,因为它总是比-U
标志有用得多(并且-U
可以安装全新的软件包),所以它是一个好答案。
应该没关系的 您可以重新创建文件。该文件的内容是:
[root@server ~]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)
[root@server ~]#
该文件属于package centos-release-7-0.1406.el7.centos.2.5.x86_64
,因此,只要您没有删除该包,只需手动触摸此文件即可。
[root@server ~]# rpm -qf /etc/redhat-release
centos-release-7-0.1406.el7.centos.2.5.x86_64