Ubuntu – Programmatically disable apt unattended upgrades


How can I programmatically/script disable apt unattended upgrades? Running Ubuntu 16.04.

Best Answer

Several methods exists:

Method One

  1. Turn off automatic upgrade by reconfiguring unattended-upgrades in the /etc/apt/apt.conf.d/50unattended-upgrades file:

    • Comment out individual lines in the Unattended-Upgrade::Allowed-Origins set of rule:-

      Unattended-Upgrade::Allowed-Origins {
          //      "${distro_id}:${distro_codename}-updates";
          //      "${distro_id}:${distro_codename}-proposed";
          //      "${distro_id}:${distro_codename}-backports";
  2. Selectively disable auto-update on a package level, by adding package names to "Unattened-Upgrade:Package-Blacklist" set of rules:

    Unattended-Upgrade::Package-Blacklist {
        //      "vim";
        //      "libc6";

Method Two

  1. Disable auto-update system-wide from the /etc/apt/apt.conf.d/10periodic file:

    • sudo nano /etc/apt/apt.conf.d/10periodic:

      APT::Periodic::Update-Package-Lists "1";
      APT::Periodic::Download-Upgradeable-Packages "0";
      APT::Periodic::AutocleanInterval "0";
      APT::Periodic::Unattended-Upgrade "0"; <--- line of interest, should be "0"

Method Three:

Go to Ubuntu Software Center, Edit --> Software Sources, choose Never for Automatically check for update

enter image description here

Source (including images):