Ubuntu – revert to an older version of a package

If you just try to install an older version of a package that you already have installed you most likely will be unable to do so without having to make some tweaks. In this case, normally aptitude will complain with a message that you already have the latest version of the package.

There is a way to get around this problem. To do so, create a file called preferences in /etc/apt. The file should contain 3 lines per each package that you want to revet to an older version. These 3 lines need to specify the package name, the version that you would like to “pin” and the priority. For example, if I wanted to revert the package libbz2-1.0_1.0.5-0.1_i386.deb to libbz2-1.0_1.0.4-2ubuntu4_i386.deb, I would put the following in the preferences file:

Package: libbz2
Pin: version 1.0_1.0.4-2
Pin-Priority: 1001

Note, that the Pin-Priority has to be over 1000 if you are going back to an older version of a package.

After I am done with this, all I have to do is execute sudo apt-get install libbz2 and I will get the older version installed.

Keep in mind that this package version will be “pinned” and no future updates to that package will be picked up by the update manager. For further information on this subject look at the man pages for apt_preferences.

Thursday, October 23rd, 2008 Linux, Ubuntu

5 Comments to Ubuntu – revert to an older version of a package

  1. Nice tip. It helps me a lot.
    Thanks man!

  2. omojj on March 6th, 2011
  3. [...] ???http://dimitar.me/ubuntu-revert-to-an-older-version-of-a-package/ [...]

  4. Debian/Ubuntu?????APT??? | Min????? – 54min.com on April 1st, 2011
  5. Thanks for the great info!
    After I added the info to preferences, and ran “sudo apt-get update” it still showed the newer version in synaptic. Am I missing something?
    Thanks again

  6. Richard on May 10th, 2011
  7. @ Richard,

    Make sure that the info in the preferences file is correct and has the older version number specified. Also, the priority needs to be high (above 1000).

    If all the info is correct then when you do sudo apt-get install package_name it should go back to the specified version in the preferences file.

  8. dimitar on May 10th, 2011
  9. I tried everything as you said but it didn’t work
    I downloaded old version of package from packages.ubuntu.com and installed manually

  10. Rauf on November 11th, 2011

Leave a comment

*

Search

 

Archive

May 2012
M T W T F S S
« Mar    
 123456
78910111213
14151617181920
21222324252627
28293031  

Other