How To List Installed Packages From A Specific Repo Using Yum?

Published July 15, 2024

Problem: Listing Packages from a Specific Repo

Identifying packages installed from a specific repository in a Linux system can be hard. This task is useful when managing software sources or fixing package-related issues. Yum, a package management tool, offers a way to do this, but the command may not be clear at first.

Solution: Using Yum with Repository Name

How to List Repo-Specific Packages

To list packages from a specific repository, use this command:

yum list installed | grep reponame

This command combines two operations:

  1. yum list installed: Lists all installed packages on your system.
  2. grep reponame: Filters the output to show only lines with the repository name.

The | symbol (pipe) connects these two commands, passing the output of the first command as input to the second.

To use this command:

  1. Open a terminal on your Linux system.
  2. Replace reponame with the name of the repository you want to check.
  3. Run the command and review the output.

This method works because yum includes the repository name when listing installed packages. By using grep to filter for the repository name, you can identify all packages from that source.

Note that the repository name in the output might be shortened or slightly different from what you expect. You may need to try a few variations to find the correct name to use with grep.

Tip: Finding the Correct Repository Name

If you're unsure about the exact repository name, you can use the yum repolist command to see a list of all enabled repositories on your system. This will show you the repository IDs, which you can then use in your grep command.

Practical Example: Listing Packages from a Specific Repository

Sample Output and Interpretation

Here's an example using the 'remi' repository, which provides updated versions of PHP and related packages:

yum list installed | grep remi
ImageMagick2.x86_64                       6.6.5.10-1.el5.remi          installed
memcache.x86_64                           1.4.5-2.el5.remi             installed
mysql.x86_64                              5.1.54-1.el5.remi            installed
mysql-devel.x86_64                        5.1.54-1.el5.remi            installed
mysql-libs.x86_64                         5.1.54-1.el5.remi            installed
mysql-server.x86_64                       5.1.54-1.el5.remi            installed
php.x86_64                                5.3.5-1.el5.remi             installed
php-cli.x86_64                            5.3.5-1.el5.remi             installed
php-common.x86_64                         5.3.5-1.el5.remi             installed

This output shows:

  1. Package Name: The first column lists the package name and architecture (e.g., ImageMagick2.x86_64).

  2. Version: The second column shows the version number of the installed package (e.g., 6.6.5.10-1).

  3. Repository: The third column indicates the repository where the package was installed from. Here, all packages show 'el5.remi', confirming they're from the remi repository.

  4. Status: The last column displays the package status, which is 'installed' for all these packages.

This example lists PHP-related packages, MySQL, and other tools from the remi repository. It shows what software components have been installed from this source, which can help with system administration and troubleshooting.

Tip: Filtering Options

You can modify the grep command to filter for specific packages. For example, to list only PHP-related packages from the remi repository, you can use:

yum list installed | grep remi | grep php

This will show only the PHP packages installed from the remi repository, making it easier to focus on specific software components.

Alternative Methods for Package Listing

Using Yum-Utils for Package Management

Yum-utils is a set of tools that adds to Yum's functions. This package gives you more options to manage packages, including ways to list packages from specific repositories.

To use yum-utils, install it with this command:

sudo yum install yum-utils

After installation, you can use these commands for repo-specific package listing:

  1. repoquery: This tool lets you query package information from repositories. To list all packages from a specific repo, use:

    repoquery --repoid=repo_name --all

    Replace 'repo_name' with the ID of the repository you want.

  2. yum-config-manager: This tool helps manage Yum configuration. It can show repository information:

    yum-config-manager --dump repo_name

    This command shows all configuration details for the specified repository.

  3. package-cleanup: While mainly used for cleaning up old packages, it can also list duplicate packages:

    package-cleanup --dupes

    This helps identify packages that might be installed from multiple repositories.

These tools from yum-utils provide more information about packages and repositories, allowing for precise package management and troubleshooting.

Tip: Combining Commands

You can combine repoquery with grep for specific results. For example:

repoquery --repoid=repo_name --all | grep package_name

This will list all versions of a specific package available in the repository.