Skip to content
Home » Articles » AUTOMATIC UPDATES FOR UBUNTU 22.04

AUTOMATIC UPDATES FOR UBUNTU 22.04

Setting up automatic updates is critical if you want to maintain a secure environment. Make sure you have automatic backups that occur prior to the updates, so you have a rollback plan.

Here are the commands to set it up.

Open a terminal:
sudo su –
apt install unattended-upgrades
systemctl status unattended-upgrades
apt install update-notifier-common
nano /etc/apt/apt.conf.d/50unattended-upgrades

Now remove the // before each of these lines, and change the values to make them relevant for your system
Unattended-Upgrade::Mail “youremailaddress@yourdomain.com”;
Unattended-Upgrade::MailReport “on-change”;
Unattended-Upgrade::Remove-Unused-Kernel-Packages “true”;
Unattended-Upgrade::Remove-Unused-Kernel-Packages “true”;
Unattended-Upgrade::Remove-Unused-Dependencies “true”;
Unattended-Upgrade::Automatic-Reboot “true”;
Unattended-Upgrade::Automatic-Reboot-WithUsers “true”;
Unattended-Upgrade::Automatic-Reboot-Time “06:00”;
Unattended-Upgrade::OnlyOnACPower “true”;

Save and Exit the file

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

Now replace the contents of the file with the info below:
APT::Periodic::Update-Package-Lists “1”;
APT::Periodic::Unattended-Upgrade “1”;

Save the File and Exit

dpkg-reconfigure -plow unattended-upgrades

Reboot your system instead of running a service restart

That’s it!