Keeping an operating system patched against newly discovered security vulnerabilities is essential for protecting personal data, network privacy, and system stability. In Ubuntu, canonical security patches and bug fixes are released regularly through the official package repositories. However, manually running terminal commands like sudo apt update && sudo apt upgrade every few days is easy to forget. By enabling the built-in unattended-upgrades package, Ubuntu can download and install critical security patches automatically in the background without user intervention.
Why Enable Automatic Security Updates?
Automating security updates offers significant advantages for everyday desktop and server users:
- Immediate Vulnerability Mitigation: Critical Common Vulnerabilities and Exposures (CVEs) affecting the Linux kernel, web browsers, or system libraries are patched as soon as updates land in Ubuntu repositories.
- Quiet Background Execution: Security updates install seamlessly in the background during system idle times, requiring zero active maintenance from desktop users.
- Targeted Security Scope: By default, automated updates only pull packages from the designated security stream (
-security), avoiding non-critical feature updates that could introduce unexpected application behaviour.
Method 1: Enable Automatic Updates via the Graphical Interface
If you prefer configuring system preferences using the Ubuntu desktop interface, follow these steps:
- Open the Ubuntu application grid and launch Software & Updates.
- Click on the Updates tab along the top of the window.
- Locate the drop-down menu labelled Automatically check for updates and set it to Daily.
- In the drop-down menu labelled When there are security updates, select Download and install automatically.
- In the drop-down menu for When there are other updates, select Display weekly or Display immediately according to your preference.
- Click Close. You will be prompted to enter your administrator password to authenticate the changes.
Ubuntu will now automatically check for, download, and install all critical security patches daily.
Method 2: Configure Unattended-Upgrades in the Terminal
For headless home servers, remote systems, or advanced users who prefer the command line, Ubuntu provides the robust unattended-upgrades utility:
Step 1: Install and Initialise the Package
Open Terminal (Ctrl + Alt + T) and run the following command to ensure the package is installed and active:
sudo apt update && sudo apt install unattended-upgrades update-notifier-common -y
Step 2: Enable the Service
Activate automatic updates by running the interactive configuration wizard:
sudo dpkg-reconfigure -plow unattended-upgrades
When the blue dialogue screen appears asking “Automatically download and install stable updates?”, use your keyboard arrow keys to highlight Yes and press Enter.
Step 3: Fine-Tune Update Preferences
To customise advanced options—such as automatic removal of obsolete kernel packages or scheduling reboots—open the configuration file in a text editor:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Review and uncomment (remove // from the start of) the following recommended parameters:
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";(automatically cleans old, unused kernel packages to conserve disk space).Unattended-Upgrade::Remove-Unused-Dependencies "true";(cleans obsolete package dependencies).Unattended-Upgrade::Automatic-Reboot "false";(leave false for desktops to prevent unexpected restarts while working).
Save changes with Ctrl + O and Enter, then exit with Ctrl + X.
Testing the Automatic Update Process
To verify that unattended upgrades are properly configured without waiting for a scheduled event, execute a dry-run test:
sudo unattended-upgrades --dry-run --debug
The terminal will output diagnostic details showing package verification, repository checks, and confirm whether security packages are ready for deployment.
Overview of Update Configuration Files
| Configuration File | Primary Purpose | Key Parameter |
|---|---|---|
/etc/apt/apt.conf.d/20auto-upgrades |
Controls update frequency and schedule timers | APT::Periodic::Unattended-Upgrade "1"; |
/etc/apt/apt.conf.d/50unattended-upgrades |
Defines package blacklist and security stream filters | Allowed-Origins { "${distro_id}:${distro_codename}-security"; } |
/var/log/unattended-upgrades/ |
Stores audit logs of all automated installations | unattended-upgrades.log |
Frequently Asked Questions
Will automatic security updates cause unexpected computer reboots?
No. By default, Automatic-Reboot is disabled in Ubuntu. When an update modifies the Linux kernel, Ubuntu will simply display a subtle restart notification in your system tray, allowing you to restart your computer whenever convenient.
Can unattended updates break my installed software?
Unattended upgrades are strictly limited to the official Ubuntu -security repository channel. These updates undergo extensive stability testing by Canonical specifically to provide critical patches with zero changes to existing software configurations.
How do I check which updates were installed automatically?
You can review the historical installation log at any time by reading the log file: cat /var/log/unattended-upgrades/unattended-upgrades.log.