[debian] apt-get install specific version of package

When you’re adding additional repositories beside the default in your /etc/apt/sources.list, Debian will provide more than one version of package where available. You can use “apt-cache policy package-name” to check the package’s available version. For example, you want to check available ffmpeg version on your repositories, you can use this command:

apt-cache policy ffmpeg

If you add additional repositories other than default, you may have several version of ffmpeg. This one is the output example on my server (I add debian-multimedia and backports repository beside the default):

root@nw:~# apt-cache policy ffmpeg
ffmpeg:
  Installed: 4:0.7.2-1~bpo60+1
  Candidate: 5:0.7.11-0.1
  Version table:
     5:0.7.11-0.1 0
        500 http://ftp.uni-kl.de/debian-multimedia/ stable/main i386 Packages
 *** 4:0.7.2-1~bpo60+1 0
        100 http://backports.debian.org/debian-backports/ squeeze-backports/main i386 Packages
        100 /var/lib/dpkg/status
     4:0.5.6-3 0
        500 http://ftp.us.debian.org/debian/ squeeze/main i386 Packages
        500 http://security.debian.org/ squeeze/updates/main i386 Packages

Those lines above show you which ffmpeg version is already installed and which one is available on other repository.
Suppose you want to install ffmpeg version 5:0.7.11-0.1 from debian-multimedia repository, you can use this command:

apt-get install ffmpeg=5:0.7.11-0.1

Notice that I put “=” and the version number [omitting the last number (0)] after the package name. That apt-get command will install ffmpeg from debian-multimedia and removing the one from backports that already installed.
When a package have some configuration file (such as Apache with it’s apache2.conf), apt-get will ask you whether to keep your current configuration or use the new version (overwrite the old one).

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>