A package manager is a set of integrated services that facilitate installing, updating, removing, and configuring packages/programs on a computer.
Talking specifically about the Linux operating system, you get to choose from a wide range of package managers, such as APT, YUM, RPM, and Pacman. Each of these package managers has some distinct feature that sets them apart from the other.
However, a relatively new package manager, Snap, has emerged as a viable alternative to traditional package managers. Let’s check out Snap, its pros and cons, and how to install and use it on Linux.
What Is Snap?
Snap is a cross-platform packaging and deployment system developed by Canonical, the makers of Ubuntu, for the Linux platform. It’s compatible with most major Linux distros, including Ubuntu, Debian, Arch Linux, Fedora, CentOS, and Manjaro.
Snap consists of three fundamental components:
Just like any other package manager, Snap also features packages called snaps. These packages, unlike their counterparts from traditional package managers, are dependency-free and easy to install.
Snaps end in the .snap extension, which is essentially a compressed filesystem that uses the SquashFS format and contains the entire package module, including the application, its dependent libraries, and additional metadata.
Snapd (or snap daemon) uses the snap metadata to set up a secure sandbox for applications on your system. Since it’s a daemon, the entire task of maintaining and managing the snap environment happens in the background.
3. Snap Store
Snaps reside in the Snap Store, and you can explore and download them just like you do with other package managers. Additionally, you also get the option to publish your own snap packages directly to the Snap Store, which is not possible with traditional package managers.
Besides these elements, Snap also has another essential component known as a channel. A channel is responsible for defining which version of a snap is installed and tracked for updates on your system. As a result, when you install or update snaps, you get the ability to specify the channel you want to proceed with for each of these operations.
- Snap: Used to refer to both the application package format and the command-line interface.
- Snapd: A Snap daemon that helps in managing and maintaining snaps.
- Snap Store: Home to all snaps; allows you to upload your own snaps and explore and install new snaps.
- Snapcraft: A framework that helps you build your own snaps.
Snap: The Good and the Bad
Ever since Canonical announced Snap, there’s been a stir in the Linux community about whether Snap is the right approach to improve package distribution on Linux. This has given rise to two opposing camps: one in favor of Snap and the other critical of its approach in the long run.
Here’s a breakdown of everything that’s good and bad about Snap.
Advantages of Using Snap
- Snaps come bundled with dependencies (libraries) that facilitate instant access to a program, as you no longer have to manually install the missing dependencies to make it work on your system.
- Each snap runs in its own containerized sandbox to avoid interference with other system packages. As a result, when you remove a snap, the system removes all of its data, including dependencies, without affecting other packages. Needless to say, this also offers a more secure environment since one package can’t access the information of another.
- Snap updates snaps automatically at set intervals. Hence, you always run the latest version of a program on your system.
- Snap makes it easier for developers to distribute their software directly to users, so they don’t have to wait for their Linux distribution to roll them out.
- Adding to the previous point, another advantage of putting developers in charge of packaging and distributing their software is that they don’t have to create distro-specific packages, as it comes bundled with the required dependencies.
Disadvantages of Snap
- Since snaps come bundled with dependencies, they’re larger in size and occupy more disk space than their counterparts from other package managers.
- As a result of the bundled dependencies, snaps are distributed as compressed filesystem images and you need to mount them first before installing. Because of this, snaps are slower to run than traditional packages.
- Although Snap enables developers to distribute their snaps directly to users, the distribution pipeline requires them to set up an account with Canonical and host their snaps on it. This goes against the true nature of the open-source methodology because even though the software is still open source, the package management system is controlled by an entity.
- Another downside to allowing developers to distribute packages is that the packages don’t go through stringent checks and reviews by the community and therefore carry the risk of containing malware—as seen a few years back.
- Due to the fact that Snap’s back-end is still closed-source and controlled by Canonical, many major Linux distros aren’t on board with the idea of putting Snap as the default package manager on their system.
With regards to the malware risk, Snap now uses automatic malware testing to scan user-uploaded packages for malicious code before it’s distributed on the Snap Store.
How to Install snapd in Linux
Since snapd is an essential component of Snap, it’s the first thing you need to install on your system. If you’re running any of the following Linux distros, though, you already get snapd pre-installed on your system: KDE Neon, Manjaro, Ubuntu (16.04/4 LTS and 20.04 LTS), Zorin OS.
In the case of some other Linux distro, you’ll need to install snapd manually.
sudo apt update
sudo apt install snapd
Installing snapd on CentOS and other RHEL-based distributions is easy:
yum install epel-release
yum install snapd
To install snapd on Fedora:
sudo dnf install snapd
On Arch Linux:
git clone https://aur.archlinux.org/snapd.git
To install snapd on Manjaro Linux:
sudo pacman -S snapd
Once installed, you need to enable the systemd unit that’s responsible for managing Snap communications on (some) Linux distros before you can use Snap.
If you’re on a Linux distro other than Ubuntu and its derivatives, run the following command to enable the snapd systemd unit:
sudo systemctl enable --now snapd.socket
Finally, restart your system with:
How to Use Snap on Linux
Using Snap is pretty similar to using other package managers. Since you’ve installed snapd on your system in the previous step, you can now access the snap tool and interact with snaps from the Snap Store easily.
Finding a Snap
With Snap, you can explore the Snap Store and find packages across different categories. So if you want to look for snaps in a particular category, use the following command syntax:
snap find package_category
snap find development
If you stumble upon a package and want to know more about it, use the info method with the default command.
snap info package_name
For example, to extract information about the GIMP snap:
snap info gimp
Installing a Snap
Finally, when you find a snap that meets your requirements, you can install it by running:
sudo snap install package_name
Once installed, you can find the program in the Applications menu of your Linux distro. You can then execute it directly from the menu or via the terminal by entering its name.
List Installed Snaps
To get a list of all the installed snaps on your system:
Viewing Version Information of a Snap
To know the current version of a snap, run:
snap list package_name
Snap automatically updates the packages installed on your system. To facilitate this, snapd, by default, is set to check for updates four times a day. However, if you want, you can modify this refresh frequency based on your preference.
Moreover, if required, you can perform an instant refresh by running:
Similarly, you can also check for an update for a snap with:
sudo snap refresh package_name
When you do so, Snap checks the channel tracked by the snap for a newer version. If an update is available, it downloads and installs it automatically.
Revert to the Previously Used Version of a Snap
If you’re experiencing problems after updating a snap, you can revert to its previous version by running:
sudo snap revert package_name
Disabling and Enabling a Snap
For times when you’re not using a snap, but might need to in the future, you can disable it temporarily and turn it back on when required. That way, you don’t have to go through the tedious process of uninstalling and reinstalling the snap.
To disable a snap, type:
sudo snap disable package_name
When you want to enable it, simply run:
sudo snap enable package_name
Removing a Snap
Lastly, to remove unused snaps on your system that you won’t probably require in the future:
sudo snap remove package_name
Successfully Setting Up Snap on Linux
If you’ve followed the guide this far, you’ll have Snap up and running on your Linux system. And subsequently, you should be able to find and download most of the packages you need. Of course, as is the case with any other package manager, it might take some time for you to get comfortable with Snap. But once you get the hang of it, you’ll be able to use it effectively.
That said, though, there are both advantages and disadvantages to using Snap, which you should take into account before getting started. If you’d like an alternative to Snap—one that aligns well with the free and open-source methodology—check out Flatpaks to get a better idea of which package manager has a better store for downloading Linux apps.
When you want to download Linux apps, how do Flathub and Snap Store compare? We pit them against each other to find out.
About The Author