This is designed to be a companion to the AptHelp page for DebianLinux users. I am not very familiar with RedhatLinux and so I will document my experiences here as I learn the commands needed to make Redhat behave. :-)

I'm a newbie to Redhat and I'm writing this as I go, so if you see any mistakes or can see something that should be added, please do.

See also: RedhatLinux, UsingApt, UsingDpkg

Contents

Files and Directories

Using The rpm Command

Basics

rpm -q redhat-release
Tells you what version of Redhat you have installed.
rpm -i <package file>
Installs the package
rpm -e <package name>
Removes all the files associated with the package. It will only remove empty directories (so if you have config files in a directory that is associated with the package it will not remove them).
rpm -qa
Lists all of the packages installed on the system.
rpm -qi <package name>
Searches the installed packages list and displays the version and and description of the package installed (assuming it is installed).
rpm -ql <package name>
Lists the contents of an installed package.
rpm -F <package file>

Freshens the package. In other words, it upgrades the package ONLY if it's already installed with a lower versions. This is useful for rpm -F /path/to/updates/*rpm

rpm -U <package file>

Upgrade the package if it's already installed or not. The -U and -F flags can be confusing. Only use -U when you know you want the file installed.

rpm -qpi <package file>

Displays the description of a package file (eg. python-1.5.2-27.rpm). Good way of checking out a package before you install it. It can also take URLs instead of local file pointers (eg. rpm -qpi http://www.domain.com/download/python-1.5.2-27.rpm).

rpm -qpl <package file>
List the contents of a package file.
rpm -qpli <package file>
List the contents and description of a package file.

Advanced

APT clones for RedhatLinux

I haven't used this yet but it claims to be an apt clone for rpm. You can find it here.

  • Having now investigated this I'm not all that impressed. I gave up after a couple hours of waiting for "rpm-get update" to complete. It looks like it requires that it actually downloads each package which is a potential installation candidate to parse the depends information. Yukky. -- AdamShand

rpmwhich

A simple BashShell function which tells you which package a file belongs to (equivelent of "dpkg -S <filename>").

rpmwhich () { 
    for f in $*;
    do
        ff=$(which $f 2>/dev/null);
        if [ -n "$ff" ]; then
            printf "%s: " $ff;
            rpm -qf $ff;
        else
            printf "'%s' not found!\n" $f;
        fi;
    done
}

Building RPM's

Rebuilding Source RPM's

Sometimes you want to customize a Redhat RPM to tweak the config files or such. This is a step by step example for rebuilding the package for AutoMount version 4 (which still isn't included by default in RedhatLinux <grr>). RPM's are typically distributed as source RPM as well as a binary RPM to make such changes easier. Here are the steps to build the autofs4 source RPM (it must be done on a Redhat box):

Install the source RPM:

Go to the installed sources:

Now untar the source tarball to somewhere and make whatever changes you need to:

Now make whatever tweaks you want to the sources:

Tar your changes back up and replace the original tarball with the one you've created.

Now build the new binary RPM package:

Install the new binary RPM:

And you're done. If you have any problems with the build carefully read the error messages and it's possible you may need to make a change to the autofs.spec file.

Building RPM's As Non Root

Stolen from the CourierImap FAQ.

First you need to create a mirror image of the main /usr/src/redhat directories in your home directory:

Use sparc, or alpha, or whatever's appropriate. Finally:

That's it, now you can build your RPM's without being root:

Useful URLs

Thanks To


CategorySoftware CategoryUnix

UsingRpm (last edited 2005-03-16 19:11:41 by AdamShand)