Skip to Content

2 ways to Install a package from a specific repository in Linux

To install a package from a specific repository in Linux, you typically use the package management system that comes with your distribution.

The exact method can vary depending on the distribution (e.g., Ubuntu, Fedora, CentOS) and the package manager (e.g., apt, yum, dnf).

Below are methods we have verified for some common distributions:

For Debian/Ubuntu (Using apt)

  1. Update the Repository Index: Before installing, it’s a good idea to update the package repository index:
    sudo apt-get update
  2. Install with Repository Specification: Use the -t option with apt-get to specify the repository:
    sudo apt-get install -t repo-name package-name

    Replace repo-name with the name of the repository and package-name with the name of the package you want to install.

For Fedora, CentOS, and RHEL (Using dnf or yum)

With dnf (Fedora) or yum (older Fedora versions, CentOS, RHEL):

  1. List Available Repositories: First, check available repositories:
    dnf repolist  # or 'yum repolist' on older systems
  2. Install Using a Specific Repository:
    • With dnf:
      sudo dnf --enablerepo=repo-name install package-name
    • With yum:
      sudo yum --enablerepo=repo-name install package-name

    Replace repo-name with the repository’s ID and package-name with the name of the package.


  • Ensure that the specific repository you want to use is already added and enabled in your system.
  • The repository name (or ID) is typically defined in the repository configuration files located in /etc/apt/sources.list and /etc/apt/sources.list.d/ (for apt) or /etc/yum.repos.d/ (for yum and dnf).
  • It is important to only install packages from trusted repositories to avoid security risks.

Remember, the exact commands might vary slightly based on the specific Linux distribution and its version. Always refer to the official documentation of your distribution for the most accurate and up-to-date information.