How to downgrade a package via apt-get?
How can I downgrade a package to an older version via apt-get
?
Other tools are also acceptable but apt-get
is preferred.
Solution 1:
If you have the version number, or the target release, apt-get
supports choosing a particular version or target release. More details can be found on manual page of apt-get. It can also be accessed from terminal by typing man apt-get
sudo apt-get install <package-name>=<package-version-number>
OR
sudo apt-get -t=<target release> install <package-name>
is the command to be run. This can be used to down-grade a package to a specific version.
Remark that when using a target release (option -t
), the release priority must greater than 1000 to allow downgrades (see man 5 apt_preferences
) otherwise the currently installed version will be kept.
It has been helpfully pointed out in the comments that
-
apt-cache showpkg <package-name>
lists all available versions. (h/t Sparhawk) -
apt-mark hold <package-name>
"holds" the package at the current version, preventing automatic upgrades. (h/t Luís de Sousa )
Solution 2:
Use:
apt-get install «pkg»=«version»
or:
sudo aptitude install «pkg»=«version»
Where:
-
«pkg»
is the name of the package. -
«version»
is the version number.