The Greatest Linux Blog on the Internets.

Ubuntu, I 'buntu, We all 'buntu, (but only if we want'u).

The Greatest Linux Blog on the Internets. header image 2

Zero hassle auto-updates for Ubuntu

February 5th, 2011 · 2 Comments · Linux, Ubuntu

I recently discovered that a feature that I’ve always wanted in Ubuntu (and Debian) already exists, and has actually been available in past releases for years. By tweaking the settings in /etc/apt/apt-conf.d/10periodic and /etc/apt/apt.conf.d/50unattended-upgrades, you can enable periodic auto-updates and auto-cleaning of downloaded package files. Essentially something equivalent to running sudo apt-get update; sudo apt-get -y –force-yes upgrade; sudo apt-get autoclean in a cron job – except in a less hackish, more ‘distro official’ way. I’ve always felt this should be an Update Manager GUI option, maybe even default behavior.

It’s documented here on the Ubuntu wiki, but below is my regurgitation of that.

First, you need the unattended-upgrades package installed:

$ sudo apt-get install unattended-upgrades

Here’s the edits I made:

Run:

$ sudo gedit /etc/apt/apt.conf.d/10periodic

Edit the file to change:

APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
from “0″ to “1″. Save.

Then edit 50unattended-upgrades:

$ sudo gedit /etc/apt/apt.conf.d/50unattended-upgrades

Uncomment (remove the slashes):

//  "${distro_id} ${distro_codename}-updates";
to become:
"${distro_id} ${distro_codename}-updates";

Save.

Now, in theory, you should get daily updates silently installed in the background, and old cached package files should be automatically cleaned up.
I can’t imagine many users think to run sudo apt-get autoclean occasionally – who would ? The unattended autoclean function enabled here is particularly nice, and IMO should be the default behaviour for Ubuntu when using the Update Manager, since it means the hard disk won’t get filled up with old cached package files after many years of updates. Don’t laugh, I’ve seen it happen :)

Tags: ···

2 Comments so far ↓

  • Lewis Bassett

    I have tried editing the files /etc/apt/apt.conf.d/10periodic and gedit /etc/apt/apt.conf.d/50unattended-upgrades and they do not exist. Have I done something wrong? I installed unattended-upgrades.

  • Tudor Dabija

    chkconfig unattended-upgrades on

    i think that one should be also included

Leave a Comment