...

How to set up automatic updates for Ubuntu Linux 18.04 nixCraft

how-to-set-up-automatic-updates-for-ubuntu-linux-18

How do I configure automatic updates for Ubuntu Linux 18.04 LTS “Bionic Beaver” server?

The Linux server security is indeed an essential task for sysadmins. One of the most fundamental ways to keep the server secure is by installing security updates on time to patch vulnerabilities. You need to install the unattended-upgrades package. It will automatically install software updated, including security updates. This page shows how to install security updates automatically when released by the Ubuntu security team.

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
    Install automatic updates for Ubuntu Linux 18.04 LTS
  3. Turn on unattended security updates, run:
    sudo dpkg-reconfigure -plow unattended-upgrades
    Configure automatic updates
  4. Configure automatic updates, enter:
    sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
    Set up alert email ID:
    Unattended-Upgrade::Mail "sysadmin@server1.cyberciti.biz";
    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_address=sysadmin@server1.cyberciti.biz
    Save and close the file.
  5. Verify that it is working by running the following command:
    sudo unattended-upgrades --dry-run
    How to Enable and Set up Automatic Unattended Security Updates on 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:
Notifications

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.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Discover more from WIREDGORILLA

Subscribe now to keep reading and get access to the full archive.

Continue reading