Ubuntu - Unattended Upgrade Ubuntu

You can enable unattended upgrades in a few simple steps.

Install unattended-upgrades:

sudo apt install unattended-upgrades

Navigate to /etc/apt/apt.conf.d

Make adjustments to 2 files:


APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

In /etc/apt/apt.conf.d/50unattended-upgrades make the following changes:

Unattended-Upgrade::Allowed-Origins {
        // Extended Security Maintenance; doesn't necessarily exist for
        // every release and this system may not have it installed, but if
        // available, the policy for updates is such that unattended-upgrades
        // should also install from here by default.
//      "${distro_id}:${distro_codename}-proposed";
//      "${distro_id}:${distro_codename}-backports";

Make sure you uncomment "${distro_id}:${distro_codename}-updates";

// Remove unused automatically installed kernel-related packages
// (kernel images, kernel headers and kernel version locked tools).
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";

// Do automatic removal of newly unused dependencies after the upgrade
Unattended-Upgrade::Remove-New-Unused-Dependencies "true";

// Do automatic removal of unused packages after the upgrade
// (equivalent to apt-get autoremove)
Unattended-Upgrade::Remove-Unused-Dependencies "true";

Test your configuration using:

unattended-upgrade --dry-run --verbose