Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am setting up a yum repository, and need to debug some of the URLs in the yum.conf file. I need to know why is Scientific Linux trying to grab this URL, when I was expecting it to grab another URL:

# yum install package [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: sl. Please verify its path and try again

The yum.conf(5) manpage gives some information about these variables:


There are a number of variables you can use to ease maintenance of yum's configuration files. They are available in the values of several options including name, baseurl and commands.

$releasever This will be replaced with the value of the version of the package listed in distroverpkg. This defaults to the version of 'redhat-release' package.

$arch This will be replaced with your architecture as listed by os.uname()[4] in Python.

$basearch This will be replaced with your base architecture in yum. For example, if your $arch is i686 your $basearch will be i386.

$YUM0-$YUM9 These will be replaced with the value of the shell environment variable of the same name. If the shell environment variable does not exist then the configuration file variable will not be replaced.

Is there a way to view these variables by using the yum commandline utility? I would prefer to not hunt down the version of the 'redhat-release' package, or manually get the value of os.uname()[4] in Python.

share|improve this question
up vote 40 down vote accepted

If you install yum-utils, that will give you yum-debug-dump which will write those variables and more debugging info to a file. There is no option to write to stdout, it will always write to some file which really isn't that helpful.

This is obviously not a great solution so here's a python one-liner you can copy and paste which will print those variables to stdout.

python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'

This works on CentOS 5 and 6, but not 4. yum is written in python, so the yum python module is already on your server, no need to install anything exra.

Here's what it looks like on CentOS 5:

[root@somebox]# python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
{'arch': 'ia32e',
 'basearch': 'x86_64',
 'releasever': '5',
 'yum0': '200',
 'yum5': 'foo'}
share|improve this answer
yum-debug-dump seems to do what I need. Looks like the information is all there under the %%%%YUM INFO section. I can't seem to make things like $YUM0-$YUM9 appear, but I never use those variables anyways. – Stefan Lasiewski Sep 7 '11 at 1:12

To get all of them you'll need to use code like mmckinst posted, but if you just want to check $releasever you can run yum version nogroups on RHEL-6.

The other thing to do, in RHEL-6, is to just create your own in /etc/yum/vars.

share|improve this answer
can you elaborate? What does creating /etc/yum/vars accomplish? Also, do you happen to know if this changed from RHEL5 to RHEL6? – Stefan Lasiewski Sep 29 '11 at 16:12
You should be able to write code which works on RHEL-5 and RHEL-6, without a problem. The version command is not in RHEL-5 atm. What I meant about /etc/yum/vars (RHEL-6 only) is that you can just create a /etc/yum/vars/foorelease ... which has your own release data in it, or even just override the system releasever by writing to /etc/yum/vars/releasever. – James Antill Oct 3 '11 at 20:07
More info about /etc/yum/vars can be found at access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/… – Stefan Lasiewski Dec 3 '12 at 19:47

Another way to see the results of variable substitution is to do something like this:

yum-config-manager -c /etc/reposyncb.conf  | grep -i spacewalk

I was tinkering with yum variables to control which spacewalk client is selected for building a local repo and found this useful to see how the variables are being interpreted.

share|improve this answer
Cool, however this method doesn't seem to provide variables like releasever. – Stefan Lasiewski Oct 1 '13 at 0:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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