Categories
Planning

How to enable automatic system updates in ubuntu

Automatic updates for Ubuntu Linux

  1. Update the server, run:
    sudo apt update && sudo apt upgrade
  2. Install unattended upgrades on Ubuntu. Type the following apt command sudo apt install unattended-upgrades apt-listchanges bsd-mailx
    How to enable automatic system updates in ubuntu
  3. Turn on unattended security updates, run:
    sudo dpkg-reconfigure -plow unattended-upgrades
    How to enable automatic system updates in ubuntu
  4. Configure automatic updates, enter:
    sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
    Set up alert email ID:
    Unattended-Upgrade::Mail “[email protected]”;
    Automatically reboot Ubuntu box WITHOUT CONFIRMATION for kernel updates:
    Unattended-Upgrade::Automatic-Reboot “true”;
    Finally edit the /etc/apt/listchanges.conf and set email ID:
    [email protected]
    Save and close the file.
  5. Verify that it is working by running the following command:
    sudo unattended-upgrades –dry-run
    How to enable automatic system updates in ubuntu

Ubuntu automatic updates sample email alert

Configuring Unattended-Upgrade::Mail in 50unattended-upgrades file enables unattended-upgrades to email a sysadmin detailing any packages that need upgrading or have problems. The Ubuntu server sent an update report via email as follows:
How to enable automatic system updates in ubuntu

See automatic updates logs

Now that you set up automatic updates on Ubuntu Server 18.04 LTS. It is time to see logs. Hence, use the grep command or cat command or more command/egrep command:
sudo cat /var/log/unattended-upgrades/unattended-upgrades.log
sudo tail -f /var/log/unattended-upgrades/unattended-upgrades.log
sudo grep ‘linux-image’ /var/log/unattended-upgrades/unattended-upgrades.log
And you are done. I hope this helps you to keep the server or virtual machine running in cloud current with the latest security updates automatically.

Conclusion

You learned how to configure automatic unattended updates for your Ubuntu Linux based server up-to-date. It is a simple and easiest way to protect your server from vulnerabilities. This method is also beneficial when you administrate multiple servers. Manually updating the system and applying patches can be a very time-consuming process. However, for a large number of servers/VMs, I would recommend something like Ansible.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far. add one

Last updated September 15, 2015 By Abhishek Prakash 4 Comments

Before seeing how to enable automatic system updates in Ubuntu, first let’s see why should we do it in the first place.

By default Ubuntu checks for updates daily. When there are security updates, it shows immediately but for other updates (i.e. regular software updates) it pop ups once a week. So, if you have been using Ubuntu for a while, this may be a familiar sight for you:

How to enable automatic system updates in ubuntu

Now if you are a normal desktop user, you don’t really care about what kind of updates are these. And this is not entirely a bad thing. You trust Ubuntu to provide you good updates, right? So, you just select ‘Install Now’ most of the time, don’t you?

And all you do is to click on Install Now, why not enable the automatic system updates? Enabling automatic system updates means all the latest updates will be automatically downloaded and installed without requiring any actions from you. Isn’t it convenient?

Enable automatic updates in Ubuntu

I am using Ubuntu 15.04 in this tutorial but the steps are the same for Ubuntu 14.04 as well.

Go to Unity Dash and look for Software & Updates:

How to enable automatic system updates in ubuntu

This will open the Software sources settings for you. Click on Updates tab here:

How to enable automatic system updates in ubuntu

In here, you’ll see the default settings which is daily check for updates and immediate notification for security updates.

How to enable automatic system updates in ubuntu

All you need to do is to change the action which reads “When there are” to “Download and install automatically”. This will download all the available updates and install them automatically.

How to enable automatic system updates in ubuntu

That’s it. Close it and you have automatic updates enabled in Ubuntu. In fact this tutorial is pretty similar to changing update notification frequency in Ubuntu.

Do you use automatic updates installation or you prefer to install them manually?

Like what you read? Please share it with others.