Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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'm writing a small 'install script' and it requires EPEL on CentOS. The command (repo url) differs according to OS bitness, how do I unify this into one command?

References: How to install EPEL

I remember doing this with uname, but am not sure how to incorporate it into the existing command.

share|improve this question

You could do this with uname -i and cat /etc/redhat-release. This would give the following:

[bart@dev ~]$ cat /etc/redhat-release
CentOS release 6.2 (Final)
[bart@dev ~]$ uname -i

I would script it like this:

rpm -Uvh`uname -i`/epel-release-5-4.noarch.rpm

(didn't test, and you would need to catch some exceptions like 404s)

share|improve this answer
rpm -Uvh`uname -i`/epel-release-5-4.noarch.rpm <- is this it? Also, since it will be running on CentOS 5 only, I don't have to handle other versions. Perhaps an add-n in the future, but not needed right now. – Christian Apr 26 '12 at 8:03
Updated above :-). – Bart De Vos Apr 26 '12 at 8:14

uname -i should output the architecture on many systems (it does on some of my i386 systems but unknown for others). If for some reason you needed to get machine type, uname -m would work.

You'd likely want to store this as a variable include the line arc=$(uname -i) in your script, and use the variable $arc as needed

share|improve this answer

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.