A chronological documentation test project, nothing serious, really!

19 Mar 2008 rpm command cheatsheet

This is a simple cheatsheet for the rpm command and can be used on systems like RedHat that uses the command

Syntax Description Example(s)
rpm -ivh {rpm-file} Install the package rpm -ivh sendmail-cf-8.14.2-1.fc8.rpm
rpm -ivh –test sendmail-8.14.2-1.fc8.rpm
rpm -Uvh {rpm-file} Upgrade package rpm -Uvh sendmail-cf-8.14.2-1.fc8.rpm
rpm -Uvh –test sendmail-8.14.2-1.fc8.rpm
rpm -ev {package} Erase/remove/ an installed package rpm -ev sendmail
rpm -ev –nodeps {package} Erase/remove/ an installed package without checking for dependencies rpm -ev –nodeps sendmail
rpm -qa Display list all installed packages rpm -qa
rpm -qa | less
rpm -qi {package} Display installed information along with package version and short description rpm -qi sendmail
rpm -ql {package-name} List files in package rpm -ql sendmail
rpm -qf {/path/to/file} Find out what package a file belongs to i.e. find what package owns the file rpm -qf /etc/passwd
rpm -qf /bin/bash
rpm -qc {pacakge-name} Display list of configuration file(s) for a package rpm -qc httpd
rpm -qcf {/path/to/file} Display list of configuration files for a command rpm -qcf /usr/bin/locate
rpm -qa –last Display list of all recently installed RPMs rpm -qa –last
rpm -qa –last | less
rpm -qpR {.rpm-file}
rpm -qR {package}
Find out what dependencies a rpm file has rpm -qpR sendmail-8.14.2-1.fc8.rpm
rpm -qR bash
rpm –test {package} Perform Installation Tests Only rpm -i –test rpm-2.0.11-1.i386.rpm
/bin/rpm conflicts with file from rpm-2.3-1
/usr/bin/gendiff conflicts with file from rpm-2.3-1
/usr/bin/rpm2cpio conflicts with file from rpm-2.3-1
/usr/bin/rpmconvert conflicts with file from rpm-2.3-1
/usr/man/man8/rpm.8 conflicts with file from rpm-2.3-1
error: rpm-2.0.11-1.i386.rpm cannot be installed
rpm –replacepkgs Install the Package Even If Already Installed. Is used to force RPM to install a package that it believes to be installed already. This option is normally used if the installed package has been damaged somehow and needs to be fixed up.

{package} – Replace with actual package name

Tags: ,

Posted by

26 Feb 2008 List rpm package content

To list the contents of a package just run the command

# rpm -ql packagename


# rpm -ql nmap


Tags: , , ,

Posted by

30 Nov 2007 Upgrade from Fedora Core 7 to Core 8

This is the steps I took to upgrade a running Fedora Core 7 installation to Core 8 using yum from the command line. Please note that live upgrades are not recommended by the Fedora Project.

Make a list of the systems current packages for later reference:

rpm -qa --qf '%{NAME}\n' | sort | uniq > ~/new-pkgnames.txt

Make a backup of any system configuration data (as root):

tar czf ~/etc-`date +%F`.tar.gz /etc

yum clean all

Make sure the new repo files isn’t placed as .rpmnew files, perhaps by

mv /etc/yum.repos.d/fedora-updates.repo.rpmnew /etc/yum.repos.d/fedora-updates.repo
mv /etc/yum.repos.d/fedora.repo.rpmnew /etc/yum.repos.d/fedora.repo

Also make sure that all the 3rd party repos you normally use point to the repository for the new Fedora release.

Next the upgrade.
Make sure you are in runlevel 3

telinit 3

Run the following command to update the yum repo on your box:

rpm -Uhv rpm -Uvh rpm -Uvh

yum might complain about conflicts or requirements. That is probably because you have used non-standard repositories or installed non-standard packages manually. Try to guess which packages cause the problem (or at least is a part of the dependency chain) – uninstall them and try again. Remember to install the packages again if they are essential.

Tip: Find and review “lost” packages.
You can find orphaned packages (ie packages not in the repositories anymore) after the upgrade with the tool package-cleanup from the yum-utils package

yum install yum-utils; package-cleanup --orphans

It’s often helpful to run this command before the update, too. For packages with a failing “%postun” script the old package will remain partly installed. Remove it with

rpm -e package-name-and-version

If you forget to remove the avahi package it will refuse to be removed from the system with a error message “error: %postun(avahi-0.6.17-1.fc7.i386) scriptlet failed, exit status 1”. I haven’t looked up this error message any further.

I had to clean yum to make it aware of the recent package change, this might not be necessary.

yum clean all
yum upgrade

Ensure that all (new) essential packages from the new version is installed with

yum groupupdate Base

You might want to update other groups too, see

yum grouplist

The system had to upgrade 937 packages before fedora Core 7 is a fedora Core 8 installation.

After the upgrade has finished a reboot is required and it was time to check for orphaned packages

package-cleanup --orphans

The command for removing these packages is described earlier.

Source:, and

Tags: , , , , ,

Posted by

26 Nov 2007 Query RPM database/packages and list their architecture

If you use the –queryformat argument with rpm it is possible to query RPMs for different architectures installed# rpm -qa --queryformat %{NAME}-%{VERSION}-%{ARCH}\\n | grep dbus-glib | sortResultdbus-glib-0.22-12.EL.5-i386dbus-glib-0.22-12.EL.5-x86_64This can also be used in one of my previous posts: Remove duplicate packages when querying the rpm database.

Tags: , , ,

Posted by

23 Nov 2007 Remove duplicate packages when querying the rpm database

Today I had to solve a RPM problem on a Red Hat Enterprise Linux WS release 4 (Nahant Update 6) system (RHEL4) where there were duplicate packages when querying the rpm database. This had happened after an upgrade to update 6 using up2date from the command line.

It seemed like i386 and x64 packages had gotten installed on some packages and this caused some problems, like logon authentication and execution of some programs.

Trying to remove a duplicate rpm package

# rpm -e libtool-libs-1.5.6-4.El4.2

gave the error message

error: "libtool-libs-1.5.6-4.El4.2" specifies multiple packages

After searching the Red Hat knowledge base I located article Why do I see duplicate packages when querying the rpm database? where it says it is necessary to specify the architecture of the package to remove.

# rpm -qa --queryformat %{NAME}-%{VERSION}-%{ARCH}\\n

If you add %{RELEASE} you can also determine if the package is from other package vendors like RPMForge.

Since this was a x64 system, I wanted to remove the i386 version

# rpm -e libtool-libs-1.5.6-4.El4.2.i386

This had to be done with every duplicate package on the system.
Locate the i386 packages that interfered with the x64 packages can be done using the command

rpm -qa | sort | uniq -d

These packages have dependencies so you have to add these manually, really fun job to do.

In RHEL5 you can use yum to remove packages in a easy way

yum remove <package>.i386
yum remove <package>.x86_64

Tags: , , , ,

Posted by