Snap is a universal package management system developed by Canonical, which allows developers and users to distribute and install software easily across various Linux distributions. Snap packages are sandboxed, automatically updated, and compatible across multiple platforms, making them a popular choice for both developers and end users.

In this guide, we’ll show you how to install a specific version of a package using Snap.

Installing Snap and Setting Up the Environment

Before you can use Snap to install specific versions of packages, you need to have Snap installed on your system. Most modern Linux distributions, like Ubuntu, come with Snap pre-installed. If it’s not installed, follow the steps below.

First, update your package list and then install Snap:

apt update
apt install snapd

Verify that Snap has been installed correctly by running:

snap version

Searching for Available Package Versions

Snap packages are available in multiple versions, often distributed through different channels. To install a specific version, you first need to find out which versions are available.

To see all available versions of a Snap package, use the snap info command:

snap info package-name

Example: Searching for available versions of the node package:

snap info node

Installing a Specific Version Using Snap

Once you have identified the version you want to install, you can specify the channel to install that version.

Installing from a Specific Channel

To install a specific version of a package, use the –channel option followed by the desired version and channel name.

snap install package-name --channel=version/stable

Example: Installing Node.js version 14 from the stable channel:

snap install node --channel=14/stable
  • –channel=14/stable: Specifies the version (14) and the channel (stable) from which the Snap should be installed.

Other Channels: Beta and Edge

In addition to the stable channel, you can also choose candidate, beta, or edge channels to install the latest development versions:

snap install package-name --channel=version/edge

Example: Installing the latest beta version of Docker:

snap install docker --channel=19.03/beta

Switching Between Installed Versions

Snap allows you to easily switch between different versions of an installed package without uninstalling.

Using snap refresh to Switch Versions

To switch to a different version of an already installed Snap, use the snap refresh command:

snap refresh package-name --channel=desired-version/stable

Example: Switching to Node.js version 14:

snap refresh node --channel=14/stable

Reverting to a Previous Version

If you want to revert to the previous version after an update, use:

snap revert package-name

Conclusion

Snap provides an easy and convenient way to install specific versions of packages. With Snap, you can also switch between versions and revert to previous ones with ease, helping you maintain control over your software environment. You can now get started using Snap package manager on dedicated server hosting from Atlantic.Net!