keepcalculator

06 Numbers and Powers

Disable Package Updates in Yum and DNF

Card No. 06·86266 · Updated · Standard formula, shown below

Yes, you can disable automatic package updates in both yum and dnf, and this article explains exactly how to do it permanently or temporarily. You’ll learn the configuration files, commands, and common pitfalls, plus how to re-enable updates when you need them.

Background: Why Updates Run Automatically

On Red Hat–based Linux distributions (RHEL, CentOS, Fedora, Rocky, AlmaLinux), package updates are normally triggered manually with yum update or dnf upgrade. However, many systems enable automatic updates through a separate service called dnf-automatic (or yum-cron on older CentOS 7 and RHEL 7). This service runs on a timer and applies security or all updates without user interaction. It is convenient for servers that need patching, but it can also cause unexpected reboots, break running applications, or consume bandwidth. Disabling it gives you full control over when changes happen.

How DNF and YUM Handle Automatic Updates

Both yum (used in RHEL/CentOS 7 and earlier) and dnf (default in Fedora, RHEL 8+, Rocky, AlmaLinux) use the same underlying concept: a systemd timer that triggers a script. The package that provides the automation is dnf-automatic on modern systems and yum-cron on legacy ones. When installed, it creates a timer unit named dnf-automatic.timer or yum-cron.timer. The timer runs daily by default, and the service it starts applies updates according to the configuration in /etc/dnf/automatic.conf or /etc/yum/yum-cron.conf.

Importantly, simply uninstalling the package is not always desirable because you might want to keep the configuration but stop the timer. You can also stop the timer temporarily with systemctl stop, but it will restart on reboot unless you disable it.

How to Disable Automatic Updates Permanently

The most reliable method is to stop and disable the systemd timer, then mask it to prevent accidental re-enablement. Here are the steps for both dnf and yum.

For DNF (Fedora, RHEL 8+, Rocky, AlmaLinux)

  1. Check if the timer is active: systemctl status dnf-automatic.timer
  2. Stop the timer for the current session: sudo systemctl stop dnf-automatic.timer
  3. Disable the timer so it does not start at boot: sudo systemctl disable dnf-automatic.timer
  4. Mask the timer to prevent any service from starting it: sudo systemctl mask dnf-automatic.timer

If you also want to prevent the dnf-automatic service from being triggered by other means, mask the service too: sudo systemctl mask dnf-automatic.service.

For YUM (CentOS 7, RHEL 7)

  1. Check the timer: systemctl status yum-cron.timer
  2. Stop it: sudo systemctl stop yum-cron.timer
  3. Disable it: sudo systemctl disable yum-cron.timer
  4. Mask it: sudo systemctl mask yum-cron.timer

Alternatively, you can remove the package entirely with sudo dnf remove dnf-automatic or sudo yum remove yum-cron, but that also deletes configuration files, which you might want later.

How to Disable Only Security Updates

If you want to keep automatic updates for security patches but stop other updates, edit the configuration file instead of disabling the timer. For dnf, open /etc/dnf/automatic.conf and set upgrade_type = security. For yum-cron, edit /etc/yum/yum-cron.conf and set update_cmd = security. This is a good middle ground for servers that must stay patched but should not change behavior unexpectedly.

How to Temporarily Pause Updates

Sometimes you only want to pause updates for a few hours while you run a critical workload. You can stop the timer without disabling or masking it, and it will resume on the next boot (if enabled) or when you start it again:

  • Stop: sudo systemctl stop dnf-automatic.timer
  • Start again later: sudo systemctl start dnf-automatic.timer

Keep in mind that if the timer was already enabled, it will start again after reboot. To make the pause persistent across reboots, you must disable it.

Common Problems and Misconceptions

One common mistake is thinking that disabling the timer also stops manual updates. It does not: you can still run sudo dnf update or sudo yum update anytime. Another misconception is that removing dnf-automatic stops all background update activity, but some systems have other mechanisms like PackageKit (on desktop Fedora) that can also check for updates. To stop PackageKit, you can disable its timer: sudo systemctl disable packagekit.service.

Another issue: if you mask the timer, you might forget about it and wonder why updates never happen. That is the point, but it also means you must manually check for updates. A safer approach is to disable the timer but not mask it, so you can easily re-enable it later.

Alternatives: Using DNF Excludes or Repositories

If you want to prevent specific packages from updating while still allowing others, you can use exclude directives in the main configuration file /etc/dnf/dnf.conf or /etc/yum.conf. For example, to exclude the kernel and a specific application:

exclude=kernel* nginx*

This is useful when a known package breaks your environment. You can also pin versions with versionlock plugin, but that is more complex. For most users, disabling the automatic timer is simpler.

Costs and Safety Considerations

Disabling automatic updates has a real security cost. Without them, your system will not receive critical security patches until you manually run an update. On internet-facing servers, this can leave you vulnerable to known exploits. The trade-off is control: you can test updates in a staging environment, schedule maintenance windows, and avoid surprise reboots. If you choose to disable, it is wise to set a reminder to check for updates weekly or monthly. Also, be aware that some compliance frameworks require automatic patching, so check your organization’s policy.

Frequently Asked Questions

Will disabling dnf-automatic stop all updates?

No, it only stops the automatic timer. Manual updates with sudo dnf update still work. Other services like PackageKit (on desktop) may also trigger updates, so disable those separately if needed.

What is the difference between disabling and masking a timer?

Disabling prevents the timer from starting at boot, but it can be started manually or by another service. Masking links the timer to /dev/null, making it impossible to start, even manually. Masking is the strongest way to ensure it never runs.

How do I re-enable automatic updates after disabling?

Run sudo systemctl unmask dnf-automatic.timer (if you masked it), then sudo systemctl enable --now dnf-automatic.timer. This will start the timer and enable it for future boots.

Is it safe to remove the dnf-automatic package?

Yes, it is safe to remove, but you lose the configuration files. If you later reinstall, you will need to reconfigure. Removing the package also stops the timer, so it is a clean way to disable updates.

Does this apply to Fedora Workstation with PackageKit?

Fedora Workstation uses PackageKit for GUI update notifications, not dnf-automatic by default. To disable those, you can disable the packagekit service: sudo systemctl disable packagekit.service. The dnf-automatic steps still apply if you have installed it manually.

Can I disable updates for a single repository?

Yes, you can set enabled=0 in the repository file under /etc/yum.repos.d/. This prevents that repository from being used for updates, but other repositories still apply.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →