Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

mehmet akar
mehmet akar

Posted on • Edited on • Originally published atmehmetakar.dev

     

Apt install specific version

Today, I want to talk about Debian-based Linux distributions focusing on "apt install specific version"
Let me explain in details.

How to Useapt to Install a Specific Version of a Package

The Advanced Package Tool (apt) is a powerful package management tool used in Debian-based Linux distributions like Ubuntu. By default,apt installs the latest available version of a package from the repositories. However, there may be situations where you need to install a specific version of a package, either for compatibility reasons or to avoid breaking dependencies. This article explains how to useapt to install a specific version of a package step by step.


Why Install a Specific Version? via apt

There are several scenarios where installing a specific version of a package becomes necessary:

  • Software Compatibility: Some applications or projects require a specific version of a library or package.
  • Bug Avoidance: A newer version of a package may introduce bugs or compatibility issues.
  • Legacy Systems: Older systems may depend on specific versions of software.

Step-by-Step Guide to Installing a Specific Version Usingapt

  1. Update the Package ListsBefore installing any package, update your package lists to ensure you have the latest information about available versions in your repositories.
sudoapt update
Enter fullscreen modeExit fullscreen mode
  1. Search for Available VersionsTo find the specific version of a package, use theapt-cache policy command. For example, to see the available versions ofnginx:
   apt-cache policy nginx
Enter fullscreen modeExit fullscreen mode

The output will display the versions available in the repositories, similar to this:

   nginx:     Installed: (none)     Candidate: 1.20.2-1ubuntu2     Version table:        1.21.6-1~ubuntu 500        1.20.2-1ubuntu2 500
Enter fullscreen modeExit fullscreen mode
  • Installed: The currently installed version (if any).
  • Candidate: The version that would be installed by default.
  • Version Table: A list of all available versions, along with their priorities.
  1. Install the Specific VersionOnce you identify the version you need, you can install it by specifying the package name and version in the following format:
sudoaptinstallpackage-name=version
Enter fullscreen modeExit fullscreen mode

For example, to install version1.20.2-1ubuntu2 ofnginx, run:

sudoaptinstallnginx=1.20.2-1ubuntu2
Enter fullscreen modeExit fullscreen mode

Ensure that you match the version string exactly as it appears in theapt-cache policy output.

  1. Hold the Package at the Specific Version (Optional)If you don’t want the package to be upgraded during a system update, you can put the package on hold:
sudoapt-mark hold package-name
Enter fullscreen modeExit fullscreen mode

For example:

sudoapt-mark hold nginx
Enter fullscreen modeExit fullscreen mode

To unhold the package and allow updates, use:

sudoapt-mark unhold package-name
Enter fullscreen modeExit fullscreen mode
  1. Verify the Installed VersionAfter installation, you can verify the installed version using theapt-cache policy command again:
   apt-cache policy package-name
Enter fullscreen modeExit fullscreen mode

For example:

   apt-cache policy nginx
Enter fullscreen modeExit fullscreen mode

The output should now show the specific version you installed as the "Installed" version.


Apt install specific version: Common Issues and Solutions

  1. Version Not Found
    If the specific version is not available, it could be due to:

    • Outdated repository data: Runsudo apt update to refresh the package lists.
    • The version is not in the currently enabled repositories. You may need to enable additional repositories or download the package manually.
  2. Dependency Conflicts
    Sometimes, installing a specific version may lead to dependency issues. In such cases:

    • Try to resolve the dependency manually by installing the required versions of other packages.
    • Consider using tools likeaptitude, which can provide alternative solutions to resolve dependencies.

Example:

sudoaptitudeinstallpackage-name=version
Enter fullscreen modeExit fullscreen mode
  1. Pinned PackagesIf a version is pinned to a lower priority, you might need to override the pinning temporarily:
sudoaptinstallpackage-name=version--allow-downgrades
Enter fullscreen modeExit fullscreen mode

Tips for Managing Specific Package Versions via apt

  • Check Changelogs: Before downgrading or locking a version, review the changelog to understand the differences between versions.
  • Backup Your System: Always create a system snapshot or backup before making significant changes to installed packages.
  • Use Virtual Environments: For libraries or programming tools, consider using tools likevirtualenv orconda to isolate dependencies.

Apt install specific version: Therefore...

Usingapt to install a specific version of a package is a straightforward process, but it requires attention to detail, especially when dealing with dependencies. By following the steps outlined in this guide, you can confidently install and manage specific package versions on your Debian-based Linux system. Always remember to test changes in a safe environment before applying them to production systems.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I am Startup Hunter & Programming-DB Geek. I will try to give some insights about fresh AI-ML & Dev. Tools Startups, programming tools, DBs, new services and its problems&solutions.
  • Location
    Bursa, Türkiye
  • Education
    Koc University, Istanbul, Türkiye.
  • Work
    Independent Researcher
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp