However, many Linux users do not know about the secret feature of the “apt” utility. So, in this short guide, we will explain the simplest way to use “apt install” to install a specific version of a package in Linux.
How to Use “Apt Install” to Install a Specific Version of a Package in Linux
First, list all the available versions of a package using the following “apt” command:
For example, we install a “testdisk” package here, and you can see that there’s only one version available.
The general syntax to install a specific version of any package is as follows:
Now, we install the “testdisk” package of the previous version using the following command:
Here, the “testdisk” of version 7.1 is successfully installed. You can also verify it using the following command:
Protect the Installed Version from Updates
Installing any specific tool version is simple, but you must lock it from the updates. So, all you have to do is run the following command to mark it as the manually installed utility:
In case you want to update the package, you need to unhold it by running the following command:
Conclusion
The “apt” command of Linux offers a simple option to install a specific version of the package. Sometimes, there are some dependencies issues where you have to install the dependencies manually. From the provided method, you can easily install the specific version of the package and accomplish the task using that particular package.