Fedora – DNF Equivalent of ‘yum update –security’

dnffedora

yum update --security installs only security updates. I think it's an extension from the yum-security plugin.

Is there an equivalent dnf command? (dnf replaced yum in Fedora 22)

Best Answer

Based on http://forums.fedoraforum.org/showthread.php?t=305905

#!/bin/bash

SECURITY_UPDATES_LIST=$( dnf --refresh -q updateinfo list sec | awk '{print $3}' )
SECURITY_UPDATES_NUM=`echo "$SECURITY_UPDATES_LIST" | sed '/^$/d' | wc -l`

if [ "$SECURITY_UPDATES_NUM" -eq 0 ]; then
  exit
fi

dnf upgrade -y $SECURITY_UPDATES_LIST
  • --refresh force repo sync
  • -y install automatically
  • SECURITY_UPDATES_NUM refined/fixed counting method, works for 0/1/infinity
Related Question