I don't know what I was trying to do but I basically deleted yum.conf
. I found an old config for yum on github but it still doesn't work. What do I do? I am using Centos 7.
2 Answers
Although I've no idea what was originally in your /etc/yum.conf
, try placing this generic/vanilla content in there.
$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://b
ugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
$
-
While this technically fixes the issue, it is also potentially unsafe. Copying entire critical config files from non-authoritative sources (with all due respect) should generally not be encouraged. It could also easily be incompatible with other versions of yum (older or newer). Reinstalling the correct package or at least fetching the file from it via a trusted source is a more sensible approach and applies to other pkgs.– nrolansSep 11, 2018 at 7:06
If you prefer to restore to the original, you can reinstall the rpm that creates the yum.conf
. First, find which rpm it comes from using rpm -qf
.
On my system,
$ rpm -qf /etc/yum.conf
yum-3.4.3-158.el7.centos.noarch
I found a copy here:
http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
To reinstall,
$ sudo rpm --reinstall http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
Alternatively, you could download the rpm, and pick it apart using rpm2cpio
:
$ mkdir /tmp/yum
$ cd /tmp/yum
$ curl http://mirror.centos.org/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm | rpm2cpio | cpio -idmv
It will now be in /tmp/yum/etc/yum.conf
Meanwhile, you may wish to start using etckeeper, which will at least keep a local backup of your /etc
in version control.
-
1Etckeeper is litteraly the very first thing I install on a new system.– hlovdalSep 8, 2018 at 17:23
yum.conf
" - do you mean you deleted just that file or that you've mangled it beyond repair, or that you've deleted other files too, or that you've broken permissions? Please be precise in your question as it might be important for a correct solution.