yum list installed packages from specific repo with code examples

Introduction:
In Linux, package management is a crucial part of system administration. It enables the installation, upgrading, and removal of software packages across different Linux distributions. Each Linux distribution has its own package manager, and they all rely on repositories to provide the packages.

For instance, in CentOS, the Yum package manager is used to manage packages, and the installed packages are listed using the "yum list installed" command. However, we can also list installed packages from a specific repository, and in this article, we will discuss how to do that with code examples.

What is a repository?
A repository is a collection of packages that are available for installation. The package manager, such as Yum, can download the packages from the repository and install them on your system. Typically, there are multiple repositories available for different Linux distributions such as CentOS, Fedora, and Debian.

Listing installed packages from specific repository:
To list installed packages from a specific repository in CentOS, we can use the Yum package manager. The Yum package manager has a command-line interface that can be used to manage packages. Here's how to list installed packages from a specific repository:

  1. First, we need to locate the repository ID. The repository ID can be found in the system repository configuration file in /etc/yum.repos.d/ directory. For instance, let's say we want to list the installed packages from the Base repository. We would look for a file with the following name: CentOS-Base.repo.

  2. Once we have located the repository file, we can view its content using the cat command. This will display the content of the file, and we can look for the repository ID in the file. The repository ID is specified in square brackets below the repository name. For instance, the repository ID for the Base repository in CentOS would look like this:

[base]

  1. Now that we have the repository ID, we can use the following command to list the installed packages from the repository:

yum list installed –disablerepo=* –enablerepo=base

In this command, we are using the –disablerepo=* parameter to disable all other repositories and –enablerepo=base to enable the Base repository. The command will list all installed packages from the Base repository.

Code examples:
Here are some code examples to list installed packages from specific repositories in CentOS:

  1. List installed packages from the Base repository:

yum list installed –disablerepo=* –enablerepo=base

  1. List installed packages from the EPEL repository:

yum list installed –disablerepo=* –enablerepo=epel

  1. List installed packages from the CentOS extras repository:

yum list installed –disablerepo=* –enablerepo=extras

Conclusion:
Listing installed packages from specific repositories is a useful feature in package management. CentOS uses the Yum package manager, which makes it easy to list installed packages from specific repositories. By disabling all other repositories and enabling the desired repository, we can list all installed packages from a specific repository. The code examples provided should help you get started with listing installed packages from specific repositories in CentOS.

here are some additional information and explanations about the previous topics covered in the article:

Package Management:
Package management is a term used to describe the various technologies and tools used to manage software packages on a Linux system. Package management is essential because it ensures that your system has the required software packages to operate efficiently. When a new package is installed, the package manager will resolve any dependencies and make sure that all required packages are installed. Package management also allows you to remove packages that are no longer required, update existing packages, and manage multiple repositories that provide various packages.

Yum Package Manager:
Yum is the default package manager for CentOS, Fedora, and many other Red Hat-based Linux distributions. It stands for Yellowdog Updater, Modified, and it simplifies the installation, update, and removal of packages on your system. Yum uses repository metadata to determine package dependencies and then downloads and installs the required packages. In CentOS, the Yum command can be used to list installed packages using "yum list installed command."

Repository:
A repository, or repo for short, is a collection of software packages that are available for installation on a Linux system. Repositories are used by the package manager to download and install software packages. Each repository consists of multiple packages, which are organized into specific categories, such as base, updates, extras, etc. The repository files are stored in the /etc/yum.repos.d/ directory, and they contain information about the repository's location, packages, and dependencies.

Disabling and Enabling Repositories:
To disable or enable repositories in CentOS, you can use the –disablerepo= and –enablerepo= parameters with the Yum command. By disabling a repository, you prevent the package manager from downloading packages from that repository. On the other hand, by enabling a repository, you ensure that the package manager uses that repository when downloading packages.

Yum List Installed Packages from Specific Repositories:
You can list installed packages from specific repositories in CentOS by using the –disablerepo= and –enablerepo= parameters with the "yum list installed" command. This command will disable all other repositories and enable the specified repo, and it will list all the installed packages from that repository. By default, "yum list installed" command lists all installed packages on the system, regardless of the repository. By specifying the repository with –enablerepo= parameter, the output will only show packages from that repository.

Conclusion:
In summary, managing packages on a Linux system is essential to ensure the system works effectively. Using a package manager such as Yum simplifies the installation, update, and removal of packages. Repositories provide a vast collection of software packages that the package manager uses to download and install software. By disabling and enabling repositories, you can customize your package manager to your system's needs. Lastly, Yum command can be used to list installed packages, and by specifying the repository with –enablerepo= parameter, you can filter packages by the repository.

Popular questions

  1. What is a repository?
    A repository is a collection of software packages that can be installed on a Linux system using a package manager such as Yum. Repositories are typically maintained by different organizations and community members who package, build, and publish open-source software.

  2. How does Yum package manager work?
    Yum package manager uses repository metadata to determine package dependencies and then downloads and installs the required packages. Yum maintains a local database of packages and their dependencies to aid in resolving package dependencies.

  3. How to list installed packages from a specific repository using Yum?
    To list installed packages from a specific repository using Yum, one can use the command "yum list installed –disablerepo=* –enablerepo=". For example, to list installed packages from the Base repository, one can use "yum list installed –disablerepo=* –enablerepo=base".

  4. What are the parameters used to disable and enable repositories in Yum command?
    The parameters used to disable and enable repositories in the Yum command are "–disablerepo=" to disable a specific repository, and "–enablerepo=" to enable a specific repository.

  5. Is it possible to list packages from multiple repositories at the same time using Yum?
    Yes, it is possible to list packages from multiple repositories at the same time using Yum by specifying multiple –enablerepo= parameters separated by a comma. For example, to list installed packages from both Base and EPEL repositories, one can use "yum list installed –disablerepo=* –enablerepo=base,epel".

Tag

Repo-pkg

I am a driven and diligent DevOps Engineer with demonstrated proficiency in automation and deployment tools, including Jenkins, Docker, Kubernetes, and Ansible. With over 2 years of experience in DevOps and Platform engineering, I specialize in Cloud computing and building infrastructures for Big-Data/Data-Analytics solutions and Cloud Migrations. I am eager to utilize my technical expertise and interpersonal skills in a demanding role and work environment. Additionally, I firmly believe that knowledge is an endless pursuit.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top