Auto Update Setup
To configure Ubuntu to automatically update and upgrade all packages, including security and general updates, follow this step-by-step documentation:
Objective
Automatically update (fetch the latest package information) and upgrade (install latest versions of installed packages) Ubuntu without manual intervention.
Step-by-Step Guide
1. Install unattended-upgrades
Ubuntu uses the unattended-upgrades package to perform automatic updates.
sudo apt update
sudo apt install unattended-upgrades
2. Enable unattended-upgrades
Enable automatic updates system-wide:
sudo dpkg-reconfigure --priority=low unattended-upgrades
- This command brings up a prompt. Choose "Yes" to enable automatic updates.
3. Configure the Update Settings
Edit the configuration file to define what gets updated:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Recommended Settings in the file:
Make sure the following lines are uncommented (no // at the beginning):
"${distro_id}:${distro_codename}-security";
"${distro_id}:${distro_codename}-updates";
"${distro_id}:${distro_codename}-backports";
🔎
${distro_id}is usuallyUbuntu, and${distro_codename}is likefocal,jammy, etc.
Optional settings you may want to enable:
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
4. Set Update Frequency
Edit or create this file:
sudo nano /etc/apt/apt.conf.d/20auto-upgrades
Insert or update these lines:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
Explanation:
-
"1"= daily -
Autoclean removes downloaded packages older than 7 days
5. Check Logs (Optional)
After auto-updates run, logs are stored here:
/var/log/unattended-upgrades/
Use:
less /var/log/unattended-upgrades/unattended-upgrades.log
✅ Verification
To simulate what will be upgraded:
sudo unattended-upgrade --dry-run --debug
🎯 Result
With these settings, your Ubuntu system will:
-
Check for updates daily
-
Automatically install all available upgrades (including security, updates, backports)
-
Reboot if needed (optional)
Let me know if you want a version tailored for servers, desktops, or containers (e.g. Docker).