​​How to Update Debian 12?


Debian stable version is released every two years with major updates. In between two stable releases, there are frequent software, security updates, and bug fixes. This is because many tested packages are added/upgraded to Debian stable version from Debian’s test version. Therefore, to keep the system secure and efficient, it is recommended to update Debian regularly. This post will demonstrate different methods of updating Debian 12 systems.

 

How to Update Debian 12 via CLI?

Debian 12 can be updated via apt packet manager, and by setting up a cronjob as demonstrated in the below sections:

Apt Packet Manager

A user can update and upgrade the system packages via the apt package manager. The following command checks for the updates from the Debian’s repository and returns the count of the packages to be upgraded:

sudo apt update

The following command returns a list of upgradeable packages:

apt list --upgradable

To Upgrade a single package, use the –only-upgrade flag along with the y option to affirm all prompts during package upgrade:

sudo apt --only-upgrade install python3-distro-info -y

The following command upgrades all upgradable packages:

sudo apt upgrade -y

Alternatively, combine the update and upgrade commands by && operator to efficiently update Debian 12:

sudo apt update && sudo apt upgrade -y

Note: Checking updates regularly can be a tedious task. Additionally, a user can miss critical updates if the user fails to check for updates regularly. Therefore, to keep the Debian 12 system(s) automatically up to date, a user can configure unattended upgrades as demonstrated in the following section.

Unattended Upgrades

Configure unattended upgrades by first updating Debian packages and then installing the unattended-upgrades package via apt packet manager:

sudo apt install unattended-upgrades

Alternatively, download and install the Debian package (deb package) of unattended-upgrades:

wget http://ftp.de.debian.org/debian/pool/main/u/unattended-upgrades/unattended-upgrades_2.9.1+nmu3_all.deb
sudo apt install ./unattended-upgrades_2.9.1+nmu3_all.deb

By default, only the security updates will be installed as the unattended-upgrades are configured for security updates. To configure the unattended-upgrades for other updates, uncomment their respective repositories by editing the 50unattended-upgrades configuration file:

sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Where:

  • updates: updates recommended updates.
  • Proposed-updates: these are proposed updates, i.e., updates that are tested and are in queue to be moved to the “updates” repository.

Press [Ctrl+O] and [Ctrl+X] to save and exit.

Next, enable the unattended-upgrades function by the following command and press Yes to create a new configuration file 20auto-upgrades:

 

sudo dpkg-reconfigure --priority=low unattended-upgrades

Finally, verify the status of unattended-upgrades by:

sudo systemctl status unattended-upgrades.service

Cronjob

A Cronjob enables a user to execute scheduled tasks. To keep Debian 12 automatically up to date, schedule automatic updates of Debian 12 packages at regular intervals via Cronjob. Cron utility is pre-installed in Debian 12, but in case, it is not installed, install cron after updating system packages by:

sudo apt install cron

Then, enable cron so it can execute in the background:

sudo systemctl enable cron

All scheduled tasks via cron are stored in the crontab file. Next, edit the crontab file:

sudo nano /etc/crontab

There are already Three (3) jobs stored in the crontab file:

To schedule a system, call to daily update Debian 12 at 1230 hrs as root user and store logs in cronupdates.log, edit the crontab file with the following commands:

25 12 * * * root /usr/bin/apt update -q -y >> /var/log/apt/cronupdates.log
30 12 * * * root /usr/bin/apt upgrade -q -y >> /var/log/apt/cronupdates.log

Press [Ctrl + O] to save and [Ctrl + X] to exit. After the crontab file is updated, it will automatically update and upgrade system packages. To view the log file, cronupdates.log, open it with any editor, like nano text editor:

sudo nano /var/log/apt/cronupdates.log

Note: it is only recommended to automatically upgrade packages to the stable version of Debian 12 and not in the development and testing Debian version.

How to Update Debian 12 via GUI?

To update Debian 12 via Graphical User Interface (GUI), launch the “Systems & Update” application from the Applications menu:

Next, click the Updates Tab:

Note: The Update tab is only visible in the Software & Updates window after unattended-upgrades is installed in the system. Install unattended-upgrades by:

sudo apt install unattended-upgrades

Next, Set up automatic updates by first, setting the frequency of checking updates:

The system will prompt for Authentication. Enter the password and press the Authenticate button:

Then, set what action to perform when there are security updates:

Select appropriate options and press Close:

Bottom Line

The stable version of Debian 12 updates regularly with security and software updates. Debian users can keep up with these updates either by frequently checking for updates or by configuring automatic updates. By CLI, Debian 12 is updated by using the default repositories, setting up a cronjob, or configuring automatic updates via unattended upgrades. By GUI, updates can be configured via the Software & Updates application.

 

Print Friendly, PDF & Email