Debian - How to display available updates

It is very easy to display available updates using application with a graphical user interface (check out apper for example) but not so obvious to do it by using shell commands only. I will shed some useful light on the subject so we could both benefit from it.

To quickly display available updates, you need to simulate upgrade action and then filter for unpack (Inst) operation.

$ apt-get -s dist-upgrade | grep ^Inst
Inst openjdk-7-jre [7u3-2.1.7-1] (7u25-2.3.10-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst icedtea-7-jre-jamvm [7u3-2.1.7-1] (7u25-2.3.10-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst openjdk-7-jre-headless [7u3-2.1.7-1] (7u25-2.3.10-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst openjdk-7-jre-lib [7u3-2.1.7-1] (7u25-2.3.10-1~deb7u1 Debian-Security:7.0/stable [all])
Inst openjdk-6-jre [6b27-1.12.5-1] (6b27-1.12.6-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst icedtea-6-jre-jamvm [6b27-1.12.5-1] (6b27-1.12.6-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst icedtea-6-jre-cacao [6b27-1.12.5-1] (6b27-1.12.6-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst openjdk-6-jre-headless [6b27-1.12.5-1] (6b27-1.12.6-1~deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst openjdk-6-jre-lib [6b27-1.12.5-1] (6b27-1.12.6-1~deb7u1 Debian-Security:7.0/stable [all])
Inst dnsutils [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst bind9-host [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst libisc84 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst libdns88 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst libisccc80 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst libisccfg82 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst liblwres80 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64]) []
Inst host [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [all]) []
Inst libbind9-80 [1:9.8.4.dfsg.P1-6+nmu2] (1:9.8.4.dfsg.P1-6+nmu2+deb7u1 Debian-Security:7.0/stable [amd64])

Preceding example does not provide very readable output, fortunately it is very easy to simplify it a bit.

$ apt-get -s dist-upgrade | grep ^Inst | cut -d\  -f2 | sort
bind9-host
dnsutils
host
icedtea-6-jre-cacao
icedtea-6-jre-jamvm
icedtea-7-jre-jamvm
libbind9-80
libdns88
libisc84
libisccc80
libisccfg82
liblwres80
openjdk-6-jre
openjdk-6-jre-headless
openjdk-6-jre-lib
openjdk-7-jre
openjdk-7-jre-headless
openjdk-7-jre-lib

Alternatively you can create longer chain of commands to pretty print desired information.

$ apt-get -s dist-upgrade | sed -r -n -e "s/^Inst (.*) \[(.*)\] \((.*) .* \[(.*)\]\).*/\1 \2 \3 \4/p" | sort | awk -F\  '{ printf "%7s\t%-25s %25s -> %-25s\n", $4, $1, $2, $3 }'
  amd64 bind9-host                   1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 dnsutils                     1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
    all host                         1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 icedtea-6-jre-cacao                   6b27-1.12.5-1 -> 6b27-1.12.6-1~deb7u1     
  amd64 icedtea-6-jre-jamvm                   6b27-1.12.5-1 -> 6b27-1.12.6-1~deb7u1     
  amd64 icedtea-7-jre-jamvm                     7u3-2.1.7-1 -> 7u25-2.3.10-1~deb7u1     
  amd64 libbind9-80                  1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 libdns88                     1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 libisc84                     1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 libisccc80                   1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 libisccfg82                  1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 liblwres80                   1:9.8.4.dfsg.P1-6+nmu2 -> 1:9.8.4.dfsg.P1-6+nmu2+deb7u1
  amd64 openjdk-6-jre-headless                6b27-1.12.5-1 -> 6b27-1.12.6-1~deb7u1     
    all openjdk-6-jre-lib                     6b27-1.12.5-1 -> 6b27-1.12.6-1~deb7u1     
  amd64 openjdk-6-jre                         6b27-1.12.5-1 -> 6b27-1.12.6-1~deb7u1     
  amd64 openjdk-7-jre-headless                  7u3-2.1.7-1 -> 7u25-2.3.10-1~deb7u1     
    all openjdk-7-jre-lib                       7u3-2.1.7-1 -> 7u25-2.3.10-1~deb7u1     
  amd64 openjdk-7-jre                           7u3-2.1.7-1 -> 7u25-2.3.10-1~deb7u1 
Notice that you do not need root privileges.
Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.

Gdansk, Poland https://sleeplessbeastie.eu