How do you see what packages are available for update

Solution 1:

As of now (Ubuntu 16.04) you can use apt list with the --upgradable flag;

sudo apt update
apt list --upgradable

and you will get a list with all upgradable packages.

Solution 2:

You could install aptitude if it isn't already installed. It's a great tool for managing packages in a headless setup.

enter image description here

Otherwise if you just want to see what's going to happen when you run something, use the --dry-run argument and it won't actually do anything, it'll just tell you what it would do:

From the apt-get man page

-s, --simulate, --just-print, --dry-run, --recon, --no-act
          No action; perform a simulation of events that would occur but do
          not actually change the system. Configuration Item:
          APT::Get::Simulate.

          Simulate prints out a series of lines each one representing a dpkg
          operation, Configure (Conf), Remove (Remv), Unpack (Inst). Square
          brackets indicate broken packages with and empty set of square
          brackets meaning breaks that are of no consequence (rare).

Add the option to the command this way

apt upgrade --dry-run

Solution 3:

Another alternative would be to use aptitude with a search term:

aptitude search '~U'

(Note the uppercase 'U')

That means: "search for all packages that are installed and can be upgraded". Reference: aptitude user's manual

By default, aptitude search shows for each package its name, description and a few flags, but you could also adapt the output to your needs. For example, to list only the package names, the command would be:

aptitude search -F '%p' --disable-columns '~U'

(--disable-columns avoids padding whitespace at the end of the lines)

Solution 4:

Below command will show you the list of installed packages which has an update available in the repositories.

dpkg --get-selections | xargs apt-cache policy {} | grep -1 Installed | sed -r 's/(:|Installed: |Candidate: )//' | uniq -u | tac | sed '/--/I,+1 d' | tac | sed '$d' | sed -n 1~2p