Programmatically disable apt unattended upgrades
How can I programmatically/script disable apt unattended upgrades? Running Ubuntu 16.04.
Several methods exists:
Method One
-
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}-security"; // "${distro_id}:${distro_codename}-updates"; // "${distro_id}:${distro_codename}-proposed"; // "${distro_id}:${distro_codename}-backports"; };
-
-
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
-
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
Source (including images):
http://ask.xmodulo.com/disable-automatic-updates-ubuntu.html
You can just remove unattended upgrades which takes a dpkg lock:
$ sudo apt-get remove unattended-upgrades
Or just disable it via configuration:
$ sudo vim /etc/apt/apt.conf.d/10periodic
and make sure to have this line with zero value:
APT::Periodic::Unattended-Upgrade "0";
Easier and less fragile method (I think less fragile than apt remove unattended-upgrades
) is:
cp /usr/share/unattended-upgrades/20auto-upgrades-disabled /etc/apt/apt.conf.d/
I've verified it by looking at /var/log/unattended-upgrades/unattended-upgrades.log