Package upgrades can be set up to install updates on Ubuntu without user intervention.
Install unattended-upgrades
apt install unattended-upgrades
Install mailx & Postfix
apt install bsd-mailx
If this does not install Postfix, install it now.
apt install postfix
This will install also install Postfix. mailx is what unattended upgrades uses to send external mail.
Configure unattended-upgrades.
Edit /etc/apt/apt.conf.d/50unattended-upgrades
. This file is mostly self explanatory. The
options can be enabled by deleting un-commenting the line. At the very least, configure the following:
Unattended-Upgrade::Mail “[email protected]”;
to allow sending notifications to your email address.Unattended-Upgrade::Automatic-Reboot “true”;
to enable auto-reboots.Unattended-Upgrade::Remove-Unused-Kernel-Packages “true”;
to remove kernelrelated packages. This is usually done using apt autoremove.Unattended-Upgrade::Remove-New-Unused-Dependencies “true”;
– remove unneeded dependancies. Also manually done with apt autoremove.Unattended-Upgrade::Remove-Unused-Dependencies “false”;
– remove unused packages, also, apt autoremove.
Restart unattended-upgrades.
systemctl restart unattended-upgrades
Edit /etc/postfix/main.cf
. Configuration of postfix is outside the scope of this article. For my
purposes, I use a relay, so I edit and uncomment relayhost =
to point to my relay.
mailx -vvv -s "Subject" [email protected]
Press CTRL D to send the email.
Test your setup.
unattended-upgrades --dry-run -–debug