How to install the latest version of a package with apt-get?

just type

apt-get update    
apt-get install <package-name>

And the latest available in all your repositories will be installed.


The selected answer works in most cases. However, you might find yourself in a situation where a more recent version is available in a backport repository which will not be installed by apt-get install <package-name> by default. For example, I recently came across this:

$ apt-cache policy golang
golang:
  Installed: 2:1.3.3-1
  Candidate: 2:1.3.3-1
  Version table:
     2:1.7~5~bpo8+1 0
        100 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages
     2:1.5.1-4~bpo8+1 0
        100 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages
 *** 2:1.3.3-1 0
        500 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status

Selecting a version from the backports can be done by specifying to install from backports: apt-get -t xenial-backports install golang.

Reference: https://help.ubuntu.com/community/UbuntuBackports#Installing_Backports


For anyone else that lands here: ttoine's answer is correct.

BUT if you are stuck with the apt-get -q -y --force-yes install openjdk-6-jdk=<blah> syntax (let's say via Chef), you can specify an asterisk/star to get the latest: apt-get -q -y --force-yes install openjdk-6-jdk=\*