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.

Ubuntu – revert to an older version of a package

5 thoughts on “Ubuntu – revert to an older version of a package

  • March 6, 2011 at 6:14 am
    Permalink

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

  • Pingback:Debian/Ubuntu?????APT??? | Min????? – 54min.com

  • May 10, 2011 at 2:50 am
    Permalink

    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

  • May 10, 2011 at 3:28 pm
    Permalink

    @ 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.

  • November 11, 2011 at 6:19 am
    Permalink

    I tried everything as you said but it didn’t work
    I downloaded old version of package from packages.ubuntu.com and installed manually

Leave a Reply

Your email address will not be published. Required fields are marked *

*