Let’s discuss the popular topic – Snaps in Linux. There are numerous Linux distributions, each distribution having its own official package manager and package format such as deb, rpm, etc. This has obvious drawbacks with developers having to package the same software multiple times for different distributions.
However, there have been multiple projects which attempted to branch out from traditional package management and develop package formats that are universal to all Linux distributions. This includes Flatpak, Appimage, and Snaps. In this article, we will be giving a basic introduction and guide to Snaps.
What are Snaps?
Snaps are a package format developed by Canonical (owner of Ubuntu). The major difference between snaps and traditional (deb, rpm) package management is the way dependencies are handled.
While traditional package managers search, download, and install dependencies when you install the package, Snaps are pre-packaged with all the dependencies.
This way snaps don’t have to download new packages at the time of installation and developers can always be assured that there are no changes to their application with changes in the system. The sandboxed and self-standing design of snaps also makes them more secure than traditional packages.
However, perhaps the biggest advantage to the sandbox design is that it enables the same build of snap packages to work on multiple distributions. Currently, distributions support snaps including Ubuntu, Debian, Arch, Fedora, CentOS, ElementaryOS, KDE Neon, Kubuntu, OpenSUSE, RedHat, Pop!_OS, Manjaro.
How to Install the Snap Package manager?
We need to install an application to install and manage all snaps. This application is called
snapd (Snap daemon) The latest versions of Ubuntu, Zorin, KDE Neon, Manjaro, and Solus come pre-installed with snapd.
Installing Snap on Debian
Run the following commands one after the other to get Snap Package manager on your Debian Linux setup.
sudo apt update sudo apt install snapd sudo apt install core
Installing Snap on Arch Linux
Run the following commands one after the other to get Snap Package manager on your Arch Linux setup.
git clone https://aur.archlinux.org/snapd.git cd snapd makepkg -si sudo systemctl enable --now snapd.socket
Installing Snap on Fedora
Run the following commands one after the other to get Snap Package manager on your Fedora Linux setup.
sudo dnf install snapd sudo ln -s /var/lib/snapd/snap /snap
Installing Snap on Linux Mint
Run the following commands one after the other to get Snap Package manager on your Linux Mint setup.
sudo mv /etc/apt/preferences.d/nosnap.pref ~/Documents/nosnap.backup sudo apt update sudo apt install snapd
Installing Snap on OpenSuse
Run the following commands one after the other to get Snap Package manager on your OpenSuse setup.
sudo zypper addrepo --refresh \ https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.3 \ snappy #Swap out Leap_15.3 for either Leap_15.2 or Tumbleweed depending on your version of openSUSE sudo zypper --gpg-auto-import-keys refresh sudo zypper dup --from snappy sudo zypper install snapd sudo systemctl enable --now snapd sudo systemctl enable --now snapd.apparmor #Only for Leap_15.3 and Tumbleweed
Tip: If you followed these steps and it doesn’t work, try logging out and logging in once to ensure the path is added to the source.
For installation instructions for more distributions and more detailed documentation, visit Snapcraft.
Managing Snap Packages on Linux
After we have installed and set up the package manager, we are ready to install Snaps.
1. Install Snaps
You can run the following command to install snap packages on your Linux Systems.
sudo snap install <snap-name>
2. Delete Snaps
Here’s how to remove a snap package that you’ve already installed on your system.
sudo snap remove <snap-name>
3. Update Snaps
Applications are auto-updating on Snap. That means that as soon as there’s a new update, the snap packages are auto updated. You can refresh the repository to check for any new updates that weren’t applied to your packages by using the snap refresh command.
sudo snap refresh <snap-name>
4. Find Snaps
If you want to lookup a package, use the snap find command. Using this command without any arguments will show the list of featured snaps, a curated list showcasing the new, interesting, or unique software available in the Snap Store
snap find <package-name>
What are channels in Snap?
Channels are used in Snap to differentiate between multiple releases of the same package. For example, a snap can have a stable release, an unstable release, and an experimental release and it is important to know which release we are following when it’s time to update.
A channel is defined by three aspects, Track, Risk, and Branch written as follows.
- Track : Defines which release we are using
- Risk : Defines if it is stable/ beta/ candidate or edge
- Branch : Optional. Usually for bug fixes.
Every package has a default channel specified by the developer which is used when no channel is specified at the time of installation.
To check the channels of your installed snaps, execute
snap list .
To specify the channel during installation, use
snap install <package-name> --channel=<channel>
This was an introduction to Snaps, a third-party package manager which aims to simplify dependency management and universalize package management in all Linux distributions. While this has been a relatively successful project, it hasn’t in any way affected the popularity of traditional package managers. To learn more about Snaps, visit Snapcraft documentation.