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:
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:
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 "firstname.lastname@example.org"; 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:
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