Finding to which package a file belongs:

 $ rpm -qif <filename>

Seeing if a package is installed:

 $ rpm -qa | grep <keyword>

Removing all packages, whatever version:

 $ rpm -e --allmatches <packagename>

Finding the ten biggest packages:

 $  rpm -qa --qf "%{SIZE} %{NAME}\n"  | sort -nr | head


Searching for packages

If you know a particular string in a package name, try this faster command:

 $ yum list ''keyword''

This only searches in package names, not its description. The asterisk and question mark wildcards work.

If you'd like to search in package names as well as descriptions:

 $ yum search ''keyword''

The keyword here is case insensitive and can use the asterisk and question mark wildcards according to development -- however on Fedora this doesn't seem to work.

Multiple keywords will return results that contain either or both keywords. So if you're looking for an FTP client, use quotes around the keywords:

 $ yum search "FTP client"

Otherwise you'll get useless results for clients of every protocol in the repository.

Finding out which package you need to install for that utility that you know by name:

 $ yum provides lsusb

To narrow the results, you can search for a particular file. For instance if you want to install a particular daemon, you probably know the file that's used to start it up:

 $ yum provides /etc/rc.d/init.d/snmpd

Groups of software

Listing all groups of packages:

 $ yum grouplist

Picking one and installing such a group:

 $ yum groupinstall Virtualization


If you have a standard desktop without any proprietary (non-opensource) drivers, you can probably get away with automatically updating:

 $ sudo yum -y update

If you run a server, you want to check what updates are available and manually select which is important for you:

 $ yum check-update

Then you can selectively do

 $ sudo yum update ''packagename''

Note that you can filter out certain packages in advance by adding a line to yum's configuration file /etc/yum.conf. In the following example, kernels are never updated:



If you want to verify whether packages are OK, you can have RPM check all packages against its database. An MD5 sum is done as well as lots of other things. This can bring up interesting things and is useful for instance when you have installed non-RPM software and you want to know what the installation script changed.

To verify all packages:

 $ sudo rpm -Va

You should run the verification of all packages as root, to avoid errors about not being able to read certain package files. The output is basically a list of lines like the following:

 S.5....T c /etc/sysconfig/rhn/sources

The first field tells us that the file Size, the MD5 sum and the modification Time aren't as was described in the RPM database. The complete list of flags can be found in the RPM man page.

Alas there is currently not a command to diff against a file to see the changes.

If you want to roll back a package to its former state (reinstall it), you can try the following commands:

 $ sudo rpm -e --justdb --nodeps packagename
 $ sudo yum -y install packagename

This can be a bit dangerous though. The first command removes the package entry from the database but doesn't delete its files. The second happily installs it again. However, yum doesn't know about 'reinstalling' so it will run the pre and post-install scripts and it depends on a package what these scripts will do.

Enabling or disabling a repository

Sometimes you just need a few packages from a repository. So you install the repository (mostly files in /etc/yum.repos.d) and use yum to install software from that repository. If you're then finished with this repository, you might remove it but it's also possible to temporarily disable it. Just edit or add the following line in the appropriate file in /etc/yum.repos.d:\