UbuntuUbuntu Based

How To Enable Automatic Security Updates on Ubuntu

Enable Automatic Security Updates on Ubuntu

In today’s digital landscape, ensuring the security of your Ubuntu system is paramount. With the ever-present threat of security breaches and vulnerabilities, keeping your system updated with the latest security patches is non-negotiable. Enabling automatic security updates on your Ubuntu system is the first line of defense against potential threats. In this comprehensive guide, we will take you through every step of the process, providing you with the knowledge and confidence to safeguard your system effectively.

Understanding Security Updates

Before diving into the process of enabling automatic security updates, let’s first understand the crucial role they play in maintaining a secure and stable Ubuntu system.

Security updates, also known as patches, are software updates specifically designed to fix vulnerabilities and weaknesses in your operating system. These vulnerabilities could be exploited by malicious actors to gain unauthorized access to your system, steal your data, or disrupt your system’s operation. By staying up to date with security updates, you not only protect your system but also your personal information and sensitive data.

Failing to apply security updates can have dire consequences. As security vulnerabilities become public knowledge, hackers actively seek to exploit them. If your system is not patched, you become a potential target. This is why enabling automatic security updates is essential – it ensures that your system is continuously protected without requiring manual intervention.

Preparing Your Ubuntu System

Before we embark on enabling automatic security updates, it’s important to prepare your system properly. Here are some essential steps to consider:

  1. Ensure Your System is Up to Date: Before automating security updates, make sure your Ubuntu system is current with all available updates. You can do this using the following command:

sudo apt update
sudo apt upgrade
  1. Backup Your Important Data: Although enabling automatic updates is a proactive security measure, it’s always prudent to create a backup of your critical data. In rare cases, system updates can cause unexpected issues, and having a backup can be a lifesaver.

  2. Prepare for System Downtime: Automatic updates may require system reboots. Be prepared for occasional downtime, especially on servers or mission-critical systems. Consider scheduling updates during off-peak hours.

Configuring Unattended-Upgrades

Now, let’s dive into the heart of enabling automatic security updates on Ubuntu by configuring Unattended-Upgrades.

Step 1: Installation of Unattended-Upgrades

If Unattended-Upgrades is not already installed on your system, you can install it with the following command:

sudo apt install unattended-upgrades

Step 2: Setting up the Configuration File

The configuration file for Unattended-Upgrades is the key to automating the update process. You can use any text editor you’re comfortable with to modify this file; we’ll use the Nano text editor in this example:

sudo nano /etc/apt/apt.conf.d/10periodic
  • Enabling Automatic Updates: To enable automatic updates, ensure that the following line is present in the file:
APT::Periodic::Unattended-Upgrade "1";
  • Selecting the Repositories to be Updated: You can specify which repositories should be automatically updated by editing the /etc/apt/apt.conf.d/50unattended-upgrades file. By default, the security repository is enabled, which is the most critical for automatic updates.

  • Scheduling Updates: You can set the frequency of updates in the configuration file. For instance, to schedule updates to run daily, you can add the following lines:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
  • Configuring Email Notifications (Optional): If you want to receive email notifications about updates, you can set the email address in the /etc/apt/apt.conf.d/50unattended-upgrades file.

Step 3: Testing the Configuration

After configuring Unattended-Upgrades, it’s essential to ensure that everything is set up correctly. Test the configuration by running the following command:

sudo unattended-upgrades --dry-run --debug

This command simulates the update process without actually applying any updates, allowing you to verify that the configuration is error-free.

Fine-Tuning Automatic Updates

Enabling automatic updates is a significant step towards a secure system, but you can fine-tune the process to suit your needs.

Whitelisting or Blacklisting Specific Packages

Sometimes, you may want to exclude specific packages from automatic updates, especially if you rely on a particular package that could break with an update. You can do this by editing the /etc/apt/apt.conf.d/50unattended-upgrades file.

  • To whitelist a package, add its name to the Unattended-Upgrade::Package-Blacklist section.
  • To blacklist a package, add its name to the Unattended-Upgrade::Package-Whitelist section.

Customizing the Upgrade Process

You can customize how upgrades are handled by editing the /etc/apt/apt.conf.d/50unattended-upgrades file. For example, you can specify whether to reboot automatically after an upgrade or only reboot if necessary:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-WithUsers "true";

Handling Package Conflicts

In some cases, you may encounter package conflicts during updates. To address this, you can configure how Unattended-Upgrades handles such conflicts. Edit the /etc/apt/apt.conf.d/10periodic file and add:

Unattended-Upgrade::AutoFixInterruptedDpkg "true";

Monitoring and Verification

After enabling automatic updates, it’s essential to monitor and verify that everything is functioning as expected.

Checking for Updates Manually

While automatic updates handle most of the work, it’s good practice to check for updates manually from time to time. You can do this with the following command:

sudo apt update
sudo apt list --upgradable

This command will display a list of available updates, allowing you to ensure that automatic updates are keeping your system current.

Reviewing Logs and Notifications

Unattended-Upgrades generates logs that can be helpful for monitoring the update process. You can find these logs in the /var/log/unattended-upgrades/ directory. Use the cat or less command to view the logs:

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

If you’ve configured email notifications, you’ll also receive alerts when updates are applied.

Verifying that Automatic Updates are Working Correctly

To confirm that automatic updates are functioning as intended, check your system’s last update timestamp:

cat /var/log/unattended-upgrades/unattended-upgrades-shutdown.log | grep "All upgrades were installed"

This command should display the date and time of the last successful update.

Troubleshooting Common Issues

While enabling automatic updates is generally straightforward, you may encounter occasional issues. Here’s how to troubleshoot and resolve them:

Identifying and Resolving Update Errors

If you encounter errors during the update process, investigate the issue by examining the logs. Common issues include:

  • Network problems: Ensure your internet connection is stable.
  • Package conflicts: Review the log files for error messages, which can provide clues on how to resolve the conflict.
  • Insufficient disk space: If your system is low on disk space, consider freeing up space or expanding your storage.

Dealing with Update Conflicts

Sometimes, package conflicts can lead to failed updates. To resolve this:

  1. Review the error messages in the logs to identify the conflicting packages.
  2. Try to resolve the conflict manually by updating the conflicting packages with the following command:
sudo apt-get -f install
  1. If manual intervention doesn’t work, consider temporarily disabling automatic updates and addressing the conflict manually before re-enabling them.

Handling Insufficient Disk Space Issues

If you encounter insufficient disk space issues during updates, consider the following steps:

  1. Identify the disk space usage using the df command. Locate the partition with low space.
  2. Clear unneeded files or move them to another storage location.
  3. If possible, expand your storage or consider deleting unnecessary packages or old kernels.

Security Best Practices

To ensure the highest level of security for your Ubuntu system, consider the following best practices:

Importance of System Hardening

Security is not just about updates; it’s about system hardening. Regularly review and implement security best practices, such as disabling unnecessary services, configuring firewalls, and implementing user access controls.

Combining Automatic and Manual Updates

While automatic updates are essential for staying current with security patches, consider supplementing them with regular manual updates. Manual updates allow you to review changes and address any potential issues immediately.

Considerations for Server and Desktop Systems

It’s important to note that server and desktop systems may have different requirements. For servers, you might want to schedule updates during maintenance windows to minimize disruption. Desktop systems can typically accommodate more frequent updates, but it’s important to strike a balance between security and convenience.


In conclusion, enabling automatic security updates on your Ubuntu system is a critical step in maintaining the security and stability of your system. By automating the update process, you reduce the risk of security vulnerabilities and ensure that your system is continuously protected.

Throughout this comprehensive guide, we’ve covered everything you need to know, from understanding the importance of security updates to the step-by-step instructions for configuring Unattended-Upgrades. We’ve also provided troubleshooting tips and highlighted security best practices.

Your Ubuntu system is now armed with the essential tools to fend off potential threats. With automatic security updates in place, you can rest assured that your system is prepared to face the ever-evolving landscape of cybersecurity. Keep your system up to date, stay vigilant, and your Ubuntu experience will be more secure than ever.


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button