Ubuntu has a built-in tool called "unattended-upgrades" that can be used to automatically install security updates. Here are the steps to set it up:
- Install the unattended-upgrades package:sudo apt-get update
sudo apt-get install unattended-upgrades
- Edit the configuration file /etc/apt/apt.conf.d/50unattended-upgrades:sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Find the line //Unattended-Upgrade::AutoFixInterruptedDpkg "false"; and uncomment it by removing the two slashes at the beginning of the line. This will ensure that the package manager does not interrupt the automatic update process.
- Edit the configuration file /etc/apt/apt.conf.d/20auto-upgrades:sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Change the value of the APT::Periodic::Update-Package-Lists option to 1 and the value of the APT::Periodic::Unattended-Upgrade option to 1. This will ensure that the package lists are updated and security updates are automatically installed.
- Restart the unattended-upgrades service:sudo systemctl restart unattended-upgrades
The service will now check for and install security updates automatically. You can also check the logs in /var/log/unattended-upgrades to ensure that everything is working as expected.
That's it! Your Ubuntu system is now set up to automatically install security updates.