How to automate updates on Ubuntu and Redhat-based Systems

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Today you will learn how to automate updates on Ubuntu and Redhat-based Systems

Ubuntu / Debian based

To automate updates on Ubuntu, you can use the built-in software called “Unattended Upgrades.” This software is included in Ubuntu by default and allows you to automate security updates and other important updates.

Here are the steps to set up Unattended Upgrades on Ubuntu:

1-Install the Unattended Upgrades package by running the following command in the terminal:

sudo apt-get install unattended-upgrades

  1. Once installed, open the configuration file for Unattended Upgrades by running the following command in the terminal:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
  1. In the configuration file, locate the line that reads //Unattended-Upgrade::Automatic-Reboot "false"; and remove the two forward slashes at the beginning of the line to enable automatic reboots after updates.
  2. Save the changes to the configuration file by pressing Ctrl+X, then Y, then Enter.
  3. By default, Unattended Upgrades only installs security updates. If you want to enable all updates, open the configuration file for the package blacklist by running the following command in the terminal:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
  1. In the configuration file, comment out (add a “#” in front of) the line that reads Unattended-Upgrade::Package-Blacklist { and the line that reads };.
  2. Save the changes to the configuration file by pressing Ctrl+X, then Y, then Enter.
  3. Finally, run the following command in the terminal to start the Unattended Upgrades service:
sudo systemctl enable unattended-upgrades.service

That’s it! Your Ubuntu system will now automatically download and install updates, and will reboot if necessary. You can check the logs for Unattended Upgrades in the file /var/log/unattended-upgrades/unattended-upgrades.log.

Redhat based Servers

in my example i will use Almalinux

To automate updates on AlmaLinux, you can use the dnf-automatic package. This package is included in AlmaLinux and allows you to automate security updates and other important updates.

Here are the steps to set up dnf-automatic on AlmaLinux:

  1. Install the dnf-automatic package by running the following command in the terminal:
sudo dnf install dnf-automatic
  1. Once installed, open the configuration file for dnf-automatic by running the following command in the terminal:
sudo nano /etc/dnf/automatic.conf
  1. In the configuration file, locate the line that reads #upgrade_type = security and remove the “#” at the beginning of the line to enable all upgrades.
  2. Save the changes to the configuration file by pressing Ctrl+X, then Y, then Enter.
  3. Enable the dnf-automatic service by running the following command in the terminal:
sudo systemctl enable --now dnf-automatic.timer
  1. This will create a cron job that runs the dnf-automatic service daily and installs all available updates.

That’s it! Your AlmaLinux system will now automatically download and install updates. You can check the logs for dnf-automatic in the file /var/log/dnf-automatic.log.

Enjoy!!

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Mel
Melhttps://unixcop.com
Unix/Linux Guru and FOSS supporter

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook