By Brendo Ross
I’m searching for a credible way to disable repositories and stop them from updating my packages. I’ve had some issue and found some ways on the internet but wanted to hear an opinion what’s best
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Accepted Answer
Hello,
There are a couple of ways to do so, depending on what you want to achieve.
If you now the exact repository you want to deny you can simply run:
- yum --disablerepo=Repo-Name
If you are not sure about the repo’s name, you can run:
- yum repolist
From there get the repo id.
There are other ways but is is the quickest I believe.
Hi @brendros,
Additionally, if you want to disable only a specific package from being updated, you can open and edit the yum.conf file, which is located in /etc/yum.conf
or in /etc/yum/yum.conf
. In the file if there isn’t a line exclude add one that way:
- exclude=php*
The above will disable all PHP packages from being updated.
If you’re using AlmaLinux 9, which is an RHEL fork like CentOS, the package manager in use is dnf
(which replaced yum
in recent RHEL-based distributions).
To disable a repository (or repositories) and stop them from updating your packages, you can follow these steps:
List Available Repositories
sudo dnf repolist
Disable a Repository
To disable a specific repository, you can use the dnf config-manager
tool. If you don’t have it installed, install the dnf-plugins-core
package:
sudo dnf install dnf-plugins-core
Now, to disable a repository, for instance epel
, you would do:
sudo dnf config-manager --set-disabled epel
Replace epel
with the name of the repository you wish to disable.
Temporary Disable During a Transaction
If you just want to temporarily exclude a repository during a specific dnf
transaction, you can use the --disablerepo
option. For example:
sudo dnf install some-package --disablerepo=epel
Permanent Disable via Configuration Files
Repositories have their configuration files located in /etc/yum.repos.d/
. To disable a repository, you can edit its respective configuration file and set enabled=0
.
For example, to disable the epel
repository:
sudo nano /etc/yum.repos.d/epel.repo
Find the section for the repository and set:
enabled=0
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.