How to Manually Enable Automatic Updates on Debian and Ubuntu 22.04 / 24.04Keeping your servers updated with the latest security patches and software updates is crucial for system stability and security. This guide will show you how to enable automatic updates on Debian and Ubuntu 22.04 / 24.04 to ensure that important updates are installed regularly.Step 1: Install Unattended UpgradesFirst, install the unattended-upgrades package, which handles automatic updates.sudo apt update && sudo apt install unattended-upgrades -yStep 2: Enable Automatic UpdatesBy default, unattended-upgrades may already be enabled, but you should verify and configure it for your needs.To check if it’s active:sudo systemctl status unattended-upgradesIf it’s inactive, enable it manually:sudo systemctl enable --now unattended-upgradesStep 3: Configure Automatic UpdatesTo customize the update settings, open the configuration file:sudo nano /etc/apt/apt.conf.d/50unattended-upgradesLook for this section:// Unattended-Upgrade::Allowed-Origins {// "${distro_id}:${distro_codename}-updates";// "${distro_id}:${distro_codename}-security";// };Uncomment the lines by removing // at the beginning to enable updates:Unattended-Upgrade::Allowed-Origins {"${distro_id}:${distro_codename}-updates";"${distro_id}:${distro_codename}-security";};Save and exit by pressing CTRL + X, then Y, and Enter.Step 4: Set Update FrequencyOpen the periodic updates configuration file:sudo nano /etc/apt/apt.conf.d/10periodicModify or add these lines to set the update interval in days:APT::Periodic::Update-Package-Lists "1";APT::Periodic::Download-Upgradeable-Packages "1";APT::Periodic::AutocleanInterval "7";APT::Periodic::Unattended-Upgrade "1";- "1" means the system will check for updates daily.- "7" means it will clean old packages weekly.Save and exit the file.Step 5: Configure Email Notifications (Optional)To receive email alerts about automatic updates, install apticron:sudo apt install apticron -yOpen the configuration file:sudo nano /etc/apticron/apticron.confFind the line that starts with EMAIL="root" and replace "root" with your email address:EMAIL="[email protected]"Save and exit.Step 6: Test Automatic UpdatesTo manually trigger an update and test the settings:sudo unattended-upgrades --dry-run --debugIf everything is configured correctly, your system will now automatically check, download, and install updates, ensuring security and stability.Would you like help configuring additional security measures or troubleshooting update issues? Let me know! 🚀 Read the full article

















