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
    Restore from your backup? – roaima Sep 7 '18 at 9:00
  • 2
    "basically deleted 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. – roaima Sep 7 '18 at 9:01
  • 1
    It is good manners to wait 24 hours before accepting an answer, to allow people from all timezones to get a chance. – loa_in_ Sep 7 '18 at 11:35
  • 2
    @loa_in_: you should tell that to the two users who encouraged OP to accept the answer. – Martin Argerami Sep 7 '18 at 11:43
  • 4
    @loa_in_ no, it's good manners to accept a helpful answer that solves the problem. People from other timezones can have a crack at other questions, no point needlessly leaving stuff on the unanswered page. – hobbs Sep 7 '18 at 13:49

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
  • 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. – nrolans Sep 11 '18 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 

I found a copy here:


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.

  • 1
    Etckeeper is litteraly the very first thing I install on a new system. – hlovdal Sep 8 '18 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.