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
- 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
- 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. - Save the changes to the configuration file by pressing
Ctrl+X
, thenY
, thenEnter
. - 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
- In the configuration file, comment out (add a “#” in front of) the line that reads
Unattended-Upgrade::Package-Blacklist {
and the line that reads};
. - Save the changes to the configuration file by pressing
Ctrl+X
, thenY
, thenEnter
. - 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:
- Install the
dnf-automatic
package by running the following command in the terminal:
sudo dnf install dnf-automatic
- Once installed, open the configuration file for
dnf-automatic
by running the following command in the terminal:
sudo nano /etc/dnf/automatic.conf
- 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. - Save the changes to the configuration file by pressing
Ctrl+X
, thenY
, thenEnter
. - Enable the
dnf-automatic
service by running the following command in the terminal:
sudo systemctl enable --now dnf-automatic.timer
- 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!!