It's easy to install a specific version of a package with apt-get:

apt-get install <package name>=<version>

For example:

apt-get install jenkins=1.517

But is there a shortcut for installing the latest version?

For example, say writing a script to automate Jenkins installation. After adding http:/q/ to /etc/apt/sources.list, Jenkins is available from two sources. Now, I'd like to tell apt-get to install the latest version without knowing exactly what the latest version is at the time the script is executed.

Is this possible in any simple way?

  • apt-get by default get the latest version. run apt-get update before to be sure – Anwar Jun 27 '15 at 5:20
up vote 11 down vote accepted

just type

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

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

  • 3
    Don't forget apt-get update before apt-get install ... to update the package lists from repositories. – Eric Carvalho Jun 3 '13 at 13:13
  • Thanks, kind of obvious... :) Earlier I've run into having an older version installed unintentionally, but maybe that was caused by forgetting to do apt-get update first. – Jonik Jun 3 '13 at 14:21

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
  Installed: 2:1.3.3-1
  Candidate: 2:1.3.3-1
  Version table:
     2:1.7~5~bpo8+1 0
        100 xenial-backports/main amd64 Packages
     2:1.5.1-4~bpo8+1 0
        100 xenial-backports/main amd64 Packages
 *** 2:1.3.3-1 0
        500 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.


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=\*

Note that to get an actual latest version of a package, you may need to add a repository to apt, a repository that holds a more current (i.e., real latest) version of the package. E.g., the openvpn documentation explains:

"Latest OpenVPN releases are available in the OpenVPN project's apt repositories. This allow you to use more up-to-date version of OpenVPN than what is typically available in your distribution's repositories."

Of course, you want to make sure you trust any repository you add. There are various ways to add a repository. I like the way they suggest in the OpenVPN docs linked above. There's also add-apt-repository.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.