Categories
Ubuntu Server

Set up unattended-upgrades on Ubuntu Server 18.04

Setting up your Ubuntu Server to auto upgrade itself is pretty easy and will save you some piece of mind once set up.

As always when you are making changes to your server, make sure to update your software repositories using:

apt update

Once this has completed you can either upgrade any out of date packages or continue with setting up auto-update.

To get started, install the package:

apt install unattended-upgrades

Once complete you will need to configure your system – we’re using VI here but feel free to use your text editor of choice:

vi /etc/apt/apt.conf.d/50unattended-upgrades

By standard unattended-upgrades only installs security updates – I generally leave this so a daily update does affect my system setup.

Find these lines in the file below – in my version they were commented out, uncomment them and set your own preferences:

Unattended-Upgrade::Mail "my@email.address";
Unattended-Upgrade::MailOnlyOnError "true";
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";

To activate the unattended-upgrades you’ll need to edit a separate file – this one was empty by default for me:

vi /etc/apt/apt.conf.d/20auto-upgrades

Add your own preferences, or simply use the ones I used below – the values equate to days:

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

You can test your unattended-upgrades by running the following:

unattended-upgrades --dry-run --debug

Leave a Reply

Your email address will not be published. Required fields are marked *