Comparing Installed vs Update Package Versions on CentOS 7 & 8

Submitted by kevin on Wed, 03/10/2021 - 21:20

When updating CentOS it can be very useful as a sysadmin to compare the incoming update package versions against the currently installed version. However this isn't an overly easy task as the installed version numbers are not printed out in the resulting dnf/yum update summary table.

Updates coming in can be seen in the summary table by running 

dnf update

However a safer command (as you have to rememeber to cancel the command) is:

dnf check-update

Next seeing installed packages can be done using:

dnf list installed

However this lists all installed packages instead of the ones we are updating. A quick AWK script can match the update package names list against the installed packages, filter to matches only and pluck out both version numbers:


update=$(dnf check-update)
installed=$(dnf list installed)

awk 'BEGIN {FS=OFS=" "} NR==FNR {v[$1]=$2; next} {print (v[$1] ? $1 " " v[$1] " " $2 : "")}' <(echo "$update") <(echo "$installed") | awk NF | column -t

This can really help spot major version numbers for programming languages, databases and other relied on packages. These may need hosted applications to be upgraded manually by development teams before the server package(s) can be safely upgraded.

Note for CentOS 7: replace dnf with yum