I have a few package installation related questions concerning RPM, YUM and CentOS and getting GCC installed:

  1. I've mounted my distribution media on my CentOS 5.2 machine but I can't seem to work out how to point RPM at the media and use that instead of looking to the internet. All the examples I've googled for appear to assume downloading the RPM's from the internet.

  2. What does the -ivh switch combo do (I'm guessing -i is for install)? I did man rpm but the switch count and combinations blew my mind.

  3. Should I be using YUM instead of RPM?

4 Answers 4


I'd recommend using yum localinstall rather than using the rpm command directly; that way you'll have the gcc package in your yum database so that it can keep track of updates. The command would just be:

yum localinstall /mnt/cdrom/CentOS/gcc-(whatever).rpm
  • Good answer, I didn't know about that.
    – Bill Weiss
    Jul 1, 2010 at 19:31
  • These were all great answers and they all got a +1 from me earlier, but this was the one got me going.
    – Kev
    Jul 2, 2010 at 6:28

You want to use something like rpm -ivh /mnt/cdrom/CentOS/gcc-(whatever).rpm. The command line options there are:

  • -i -- install (you can use -U to install or upgrade, many just always use that)
  • -v -- verbose output
  • -h -- show hashmarks, a simplistic progress bar

Yum will figure out which package you mean if you type yum install gcc. That'll use your chosen repository, or the CD if you've got the correct repository installed (which you probably do). In general, yum is easier to use if you're not doing anything strange.


There is probably already a repo defined in yum for the centos media that you can use that just needs to be enabled. The documentation included in the file shows you how you could disable all your remote repos, enable just the local media repo and install your software package from cd.

$ cat /etc/yum.repos.d/CentOS-Media.repo 
# CentOS-Media.repo
# This repo is used to mount the default locations for a CDROM / DVD on
#  CentOS-5.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c5-media [command]
# or for ONLY the media repo, do this:
#  yum --disablerepo=\* --enablerepo=c5-media [command]

name=CentOS-$releasever - Media
  • If you are going to go with a yum localinstall keep in mind that it usually works best when the package being installed has no dependencies. That's why setting up the local DVD repo as mtinberg/Rajat explained is not overkill, because it won't be the last time you install something from the DVD. I can't believe that yum did not go out on the internet to resolve the dependencies on binutils, cpp, and glibc-devel. Am I missing something?
    – Allen
    Jul 4, 2010 at 19:47

1 step rpm -ivh vsftpd.x86_64 0:2.2.2-7.rpm

2 step rpm -ivh createrepo-0.9.8-4.rpm

3 step copy every thing from DVD or .iso to /var/ftp/pub (cp -av /var/ftp/pub)

4 step createrepo -v /var/ftp/pub/

5 step vi /etc/yum.repos.d/base.repo

6 step

[base] name=Server Software baseurl= enabled=1 gpgcheck=0

7 step yum install gcc -y

  • "Set up a local package repository" seems like overkill for "hey, how do I install a package?", doesn't it?
    – Bill Weiss
    Jul 1, 2010 at 19:32
  • yum install <package> -y
    – Rajat
    Jul 2, 2010 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .