Command to check version [duplicate]

There are a lot of different solutions/workarounds I'm going to mention some:

1. Find installed version

1.1. dpkg

Use dpkg -l pkg-name to get package version, e.g:

$ dpkg -l firefox

it's going to give you some information:

||/ Name         Version                  Architecture    Description
+++-==========================================================================
ii  firefox      53.0.3+build1-0ubuntu0.  amd64           Safe and easy web brow

1.2. pkg --version

Depends on your package switches like -v or --version might be available to you:

firefox -v

2. Last available version

2.1. apt show

Then use sudo apt update to make sure your sources are up to date, and use apt show firefox | grep -i version to see the last version available.

2.2. Ubuntu packages database

You can also check https://packages.ubuntu.com to search for your package version.

2.3. apt changelog

As an alternative you can use apt changelog pkg-name, e.g apt changelog firefox this will connect to internet to get the last "change log" data so you don't have to update your sources for using this command.

2.4. rmadison

The other option is rmadison, it remotely query the archive database about a packages, so you don't have to update your source in this option.

First install its package: sudo apt install devscripts, then use it like:

 rmadison -s zesty -a amd64  wget

it give you last available version of wget for "zesty" and "amd64" architecture.


Check if upgrades are available for a particular package

It is possible to use apt-cache like this,

$ apt-cache policy <package-name>  # generic

$ apt-cache policy firefox         # example with output
firefox:
  Installed: 53.0.3+build1-0ubuntu0.16.04.2
  Candidate: 53.0.3+build1-0ubuntu0.16.04.2
  Version table:
 *** 53.0.3+build1-0ubuntu0.16.04.2 500
        500 http://se.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
        100 /var/lib/dpkg/status
     45.0.2+build1-0ubuntu1 500
        500 http://se.archive.ubuntu.com/ubuntu xenial/main i386 Packages

Update source list

Update listing the sources

sudo apt-get update

or (newer syntax)

sudo apt update

Upgrade a package

Upgrade a particular package (and whatever is needed to support the new version)

sudo apt-get install <package-name>

or (newer syntax)

sudp apt install <package-name>

Upgrade all installed packages

Upgrade the installed packages, which have upgrades available

sudo apt-get dist-upgrade

or (newer syntax)

sudo apt upgrade

or

sudo apt full-upgrade

Man pages

See the manual pages

man apt-get

and

man apt

for more details.


If you are looking to patch a server for only a particular package you can do sudo apt-get install --only-upgrade <packagename>. This will upgrade only that single package, and only if it is installed. You can then use <packagename> --version to verify the current version of the installed package. You can also use dpkg -l | awk '$2=="<packagename>" { print $3 }' to verify the version as well.