Set up automatic unattended updates for Ubuntu 20.04

Ubuntu 20.04 includes a built-in tool called “unattended-upgrades” that allows you to set up automatic updates. Here’s how you can set it up:

  1. First, install the package by running the command “sudo apt install unattended-upgrades”
  2. Next, configure the package by editing the “/etc/apt/apt.conf.d/50unattended-upgrades” file. In this file, you can set the parameters for the automatic updates such as which packages to update, when to update, and how to notify of updates.
  3. You can also configure which updates to install by editing the file “/etc/apt/apt.conf.d/20auto-upgrades” and uncommenting the line “Unattended-Upgrade::Allowed-Origins {“;
  4. You can configure the frequency of the updates by editing the file “/etc/apt/apt.conf.d/10periodic” and uncommenting the line “APT::Periodic::Unattended-Upgrade “1”;”
  5. Once you’ve finished configuring the package, you can start it by running the command “sudo systemctl start unattended-upgrades”
  6. To check the status of the package, you can run the command “sudo systemctl status unattended-upgrades”
  7. To make sure the package starts automatically after a reboot, you can run the command “sudo systemctl enable unattended-upgrades”

Please note that the package “unattended-upgrades” only updates packages that are considered security or important updates, not all updates.

You can also use other tools like “apticron” and “apt-listchanges” to configure automatic updates and to notify of updates via email. It’s also important to check the log files in “/var/log/unattended-upgrades” to confirm that the updates were installed successfully and to troubleshoot any issues.

Please be aware that automatic updates can cause unexpected issues and it’s recommended to test updates in a staging environment before applying them to production systems.

(https://www.algerie360.com)

Leave a Comment