✅ How to Configure Automatic Updates in Ubuntu



 How to Configure Automatic Updates in Ubuntu


Ubuntu allows you to enable automatic updates for security, system, and application updates. You can configure this via the GUI (Software Updater) or Terminal.



---


Method 1: Configure Automatic Updates via GUI (Recommended for Beginners)


1. Open "Software & Updates"


Click Activities → Search for Software & Updates → Open it.




2. Go to the "Updates" Tab


Under "Automatically check for updates", select Daily.


Under "When there are security updates", select Download and install automatically.


Under "When there are other updates", select Display immediately or Download automatically.




3. Close the window – The settings will be saved automatically.





---


Method 2: Configure Automatic Updates via Terminal (Advanced Users)


1. Enable Unattended Upgrades


Ubuntu includes a package called unattended-upgrades, which is used for automatic updates. Install it if it's not already installed:


sudo apt update && sudo apt install unattended-upgrades -y


2. Configure Unattended Upgrades


Edit the configuration file:


sudo nano /etc/apt/apt.conf.d/50unattended-upgrades


Look for the following lines and ensure they are uncommented (remove // if present):


Unattended-Upgrade::Allowed-Origins {

    "o=Ubuntu,a=jammy-security";

    "o=Ubuntu,a=jammy-updates";

};


(Optional) Enable automatic removal of old packages:


Unattended-Upgrade::Remove-Unused-Dependencies "true";


Save & Exit: Press CTRL + X, then Y, then Enter.



3. Enable Automatic Updates


Run the following command to configure auto-updates:


sudo dpkg-reconfigure unattended-upgrades


Select "Yes" when prompted.



4. (Optional) Set Update Schedule


Edit the auto-update schedule:


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


Ensure it contains:


APT::Periodic::Update-Package-Lists "1";

APT::Periodic::Unattended-Upgrade "1";


The "1" means daily updates. Increase the number for less frequent updates.


Save & Exit: Press CTRL + X, then Y, then Enter.




---


Method 3: Use Cron Job for More Control (Optional)


If you want updates to run at a specific time, add a cron job:


sudo crontab -e


Add this line to update the system daily at 2 AM:


0 2 * * * /usr/bin/apt update && /usr/bin/apt upgrade -y


Save & Exit: Press CTRL + X, then Y, then Enter.




---


Check If Auto-Updates Are Working


To check logs and verify updates are running:


cat /var/log/unattended-upgrades/unattended-upgrades.log



---


Now, Ubuntu will automatically download and install updates based on your settings.

.


ليست هناك تعليقات:

إرسال تعليق