How to keep Debian Linux patched with latest security updates automatically

How to keep Debian Linux patched with latest security updates automatically

To keep a Debian Linux system patched with the latest security updates automatically, you can use the unattended-upgrades package. This package allows you to configure automatic installation of security updates on your system.

To install unattended-upgrades on Debian, follow these steps:

  1. Update the package manager's package list by running the following command:
r‮‬efer to:lautturi.com
sudo apt-get update
  1. Install the unattended-upgrades package by running the following command:
sudo apt-get install unattended-upgrades

This will install the unattended-upgrades package and any dependencies required.

  1. To enable automatic installation of security updates, open the /etc/apt/apt.conf.d/50unattended-upgrades file in a text editor and uncomment the following line:
Unattended-Upgrade::Automatic-Reboot "true";

This will enable automatic reboots when required by an upgrade.

  1. To specify which packages should be upgraded automatically, open the /etc/apt/apt.conf.d/20auto-upgrades file in a text editor and uncomment the following line:
APT::Periodic::Unattended-Upgrade "1";

This will enable automatic upgrading of all packages, including security updates.

  1. To specify which repositories should be used for automatic upgrades, open the /etc/apt/apt.conf.d/20auto-upgrades file in a text editor and uncomment the following lines:
Unattended-Upgrade::Origins-Pattern {
    "o=Debian,a=stable";
    "o=Debian,a=stable-updates";
};

This will enable automatic upgrades from the stable and stable-updates repositories.

  1. To configure automatic installation of security updates, open the /etc/apt/apt.conf.d/50unattended-upgrades file in a text editor and uncomment the following lines:
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "01:00";

This will enable automatic reboots when required by an upgrade and set the reboot time to 1:00 AM.

That's it! unattended-upgrades is now configured to automatically install security updates on your Debian Linux system. The system will check for updates daily and install them automatically if they are available. If a reboot is required, it will be scheduled for 1:00 AM.

Created Time:2017-10-16 14:38:50  Author:lautturi