Skip to content

Instantly share code, notes, and snippets.

@Aldaviva
Last active April 15, 2025 15:54
Show Gist options
  • Save Aldaviva/9db64e47324f467a7c9b7e468a454c76 to your computer and use it in GitHub Desktop.
Save Aldaviva/9db64e47324f467a7c9b7e468a454c76 to your computer and use it in GitHub Desktop.
Enable automatic updates in Fedora and Debian
  1. Install plugin

    sudo apt install unattended-upgrades
  2. Edit package behavior

    Create a new configuration override file and set its contents to the following, changing values to your liking.

    sudo $EDITOR /etc/apt/apt.conf.d/51unattended-upgrades-local
    Unattended-Upgrade::Origins-Pattern {
        "origin=*";
    };
    
    Unattended-Upgrade::Automatic-Reboot "false";
    

    This will upgrade all packages, regardless of which repository they come from. It won't reboot after installing upgrades.

See Debian Reference § 2.7.3: Automatic download and upgrade of packages, /etc/apt/apt.conf.d/50unattended-upgrades and /usr/share/doc/unattended-upgrades/README.md.gz for documentation, defaults, and examples.

  1. Install plugin
    sudo dnf install dnf5-plugin-automatic
  2. Edit plugin behavior
    sudo cp /usr/share/dnf5/dnf5-plugins/automatic.conf /etc/dnf/automatic.conf
    sudo $EDITOR /etc/dnf/automatic.conf
    commands.apply_updates can be set to yes to actually install the updates instead of only downloading them
  3. Edit timer
    sudo systemctl edit dnf5-automatic.timer
    For example, to make DNF install updates at exactly 1:05 AM every day, you can set the file contents to
    [Timer]
    # Empty string disables the default 6-7 AM update
    OnCalendar=
    OnCalendar=*-*-* 1:05
    RandomizedDelaySec=0
    more systemd timer examples
  4. Enable timer
    sudo systemctl enable --now dnf5-automatic.timer
  5. Verify timer status
    systemctl status dnf5-automatic.timer
    systemctl list-timers --all dnf5-automatic
@nikodunk
Copy link

nikodunk commented Apr 9, 2025

Interesting! Yes if you need it to reboot at a specific time, and prefer to have your files pre-populated with configs then that totally makes sense. I prefer an empty config file and to build up.

I'm pretty sure the config format didn't change between dnf5-automatic and dnf-automatic, though? Can't find any reference to them changing online. Edit: wait I see what you mean! The config format hasn't changed, but the pre-configured automatic timers have been removed from dnf5-automatic plugin!! https://dnf5.readthedocs.io/en/latest/changes_from_dnf4.7.html#changes-to-individual-commands. I'll update the Fedora docs to reflect this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment