Skip to main content
Prerequisites:
  • Ubuntu or Debian-based Linux system
  • Root or sudo access
  • Internet connection
Keeping your Linux system updated is crucial for security. This guide shows you how to set up automatic upgrades using unattended-upgrades to ensure your system receives security patches automatically.

Manual System Updates

Before setting up automatic upgrades, understand the basic update commands:
1

Update package lists

Refresh the package index to get the latest information about available packages:
This downloads package information from all configured repositories.
2

Upgrade installed packages

Upgrade all installed packages to their latest versions:
You can also combine both commands:
3

Full system upgrade (optional)

For a complete system upgrade including kernel updates:
full-upgrade may remove packages if necessary to resolve dependencies. Use with caution on production systems.

Installing Unattended-Upgrades

1

Install unattended-upgrades

Install the unattended-upgrades package:
2

Verify installation

Check that the service is installed and running:

Configuring Unattended-Upgrades

Configure unattended-upgrades to automatically install security updates.
1

Run configuration wizard

Launch the interactive configuration tool:
You’ll be presented with a series of prompts:
  1. Automatically download and install stable updates? - Select “Yes”
  2. Email address for update notifications - Enter your email (optional)
  3. Automatic reboot options - Choose based on your needs
2

Manual configuration (alternative)

If you prefer manual configuration, edit the configuration file:

Configuration File Settings

The main configuration file is located at /etc/apt/apt.conf.d/50unattended-upgrades. Here are key settings:
Specify which updates to install. The default configuration includes:
This ensures only security updates are installed automatically.
Prevent specific packages from being automatically updated:
Useful for packages that require manual intervention or testing.
Configure automatic reboots after updates:
Automatic reboots can disrupt services. Only enable if your system can handle unexpected reboots.
Receive email notifications about updates:
Set MailOnlyOnError to false to receive notifications for all updates.
Automatically remove unused packages after updates:

Enable Automatic Updates

1

Enable automatic updates

Create or edit the auto-update configuration file:
Add the following configuration:
2

Configuration values explained

  • Update-Package-Lists "1" - Update package lists daily
  • Unattended-Upgrade "1" - Run unattended-upgrade daily
  • Download-Upgradeable-Packages "1" - Download upgradeable packages daily
  • AutocleanInterval "7" - Clean package cache every 7 days
Values are in days. Use "0" to disable a feature.
3

Verify configuration

Check that automatic updates are enabled:

Testing Unattended-Upgrades

1

Test configuration

Test the configuration without making changes:
This shows what would be updated without actually installing anything.
2

Manually trigger updates

Force unattended-upgrades to run immediately:
3

Check update logs

View logs to see what updates were installed:

Monitoring Automatic Upgrades

View the current status of automatic updates:
Check what updates have been installed:
See what updates are available:
Check if the unattended-upgrades service is running:
Here’s a complete recommended configuration for production servers:

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

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

Disabling Automatic Upgrades

If you need to disable automatic upgrades:
1

Disable automatic updates

Edit the configuration file:
Change values to "0" to disable:
2

Stop the service

Stop and disable the unattended-upgrades service:

Troubleshooting

Check:
  1. Service status: sudo systemctl status unattended-upgrades
  2. Configuration files: cat /etc/apt/apt.conf.d/20auto-upgrades
  3. Logs: sudo tail -f /var/log/unattended-upgrades/unattended-upgrades.log
  4. Test manually: sudo unattended-upgrades --dry-run
Reduce notification frequency:
Or disable email notifications entirely by removing or commenting out the Mail line.
Add packages to the blacklist in /etc/apt/apt.conf.d/50unattended-upgrades:
Disable automatic reboots:
Then restart the service:
Automatic updates can fill up disk space. Enable automatic cleanup:
Manually clean up:

Best Practices

Security Updates Only

Configure to install only security updates automatically. Regular updates can be done manually after testing.

Email Notifications

Set up email notifications to monitor what updates are being installed.

Package Blacklist

Blacklist critical packages that require manual testing before updates.

Regular Monitoring

Review logs weekly to ensure updates are installing correctly.

Backup Before Updates

Ensure you have backups before enabling automatic updates on production systems.

Test Environment

Test automatic updates in a staging environment before enabling on production.

Quick Reference

1

Install and configure

2

Manual update

3

Check status

Important: While automatic updates improve security, always test updates in a staging environment first, especially for production systems. Consider blacklisting critical packages that require manual testing.
Last modified on January 26, 2026