When you install Linux software packages with snap, you can say goodbye to the hell of dependencies and the removal of other functional applications. Snap packages were originally designed for Ubuntu, but are now available on various Linux distributions.
What are Snap packages?
In the past, installing applications on Linux was a potentially frustrating experience. You would install something only to find a particular library or other missing or obsolete dependency. You would then track down the missing resource and install it, only to find another application depended on the version of the library you just replaced. Attach one, break one, repeat.
This has improved with better package management systems, such as apt, dnf, and Pac-Man. However, you are still having trouble if you need to install different versions of the same application. Or, if you are using two applications that compete because they are linked to specific, but different, versions of a library.
One solution to these problems is the implementation of applications and deployment systems. Snappy is one of the most popular of them. It is based on a packaging and deployment system called Click, which refers to the Ubuntu Touch initiative. AppImage and FlatPack you may have met others.
These systems encapsulate the application with all dependencies and other requirements in a single compressed file. The application then runs in a kind of mini-container. It is placed in a sandbox and separated from other applications. The libraries and other resources with which the application is supplied or which it needs are available only for itself.
They are not installed in the traditional sense of the term, so they are not a problem with other applications that require different versions of the same resources. You can even install and run applications that require conflicting library versions because each application is in its own sandbox.
If they are not installed in the usual way, how are they treated? Well, the single package file is downloaded, decompressed and mounted as SquashFSvirtual file system. It is then presented to you as a virtual environment. All of this takes place behind the scenes. All you know is that you installed an application and now have access to it.
Of course, since each package file must contain all of the resources that the application needs, the package files can be large. It’s also easy to duplicate a resource that you would normally only install once, like MySQL or Apache. If two different snap applications require the same resources, they each bring their own copy.
It is the compromise for the simplicity of installation and the elimination of headaches linked to resource conflicts.
Installation of snapd
Snappy was introduced with Ubuntu 16.04, so if you are using this version or later, you are ready to go. On our machine, Snappy was installed on Manjaro 18.04, but we had to install it on Fedora 31.
snap is both the name of the package files and the command you use to interact with them. Behind the scenes, the snapd daemon is also the name of the package you should install if you don’t already have Snappy on your computer.
To install snapd on Fedora, type the following command:
sudo dnf install snapd
If you need to install it on Manjaro, use these commands:
sudo pacman -Sy snapd
sudo systemctl enable –now snapd.socket
You can use the snap version command to see the version of the snap client, the snapd daemon, and the software serial number. The name and version of your Linux distribution and the kernel version will also be displayed for you.
Type the following:
Installing snap packages
It’s a fairly simple process to install a snap package. You can use snap to find snap packages and then install the one you want.
We type the following to find and install gimp image editor:
snap find gimp
snap searches for matches to the “gimp” search index and returns its results. It will find everything that matches or mentions the search term.
To install one of the packages, we use the value in the Name column, as shown below:
sudo snap install gimp
As the download progresses, the percentage of success achieved increases and a progress bar slides to the left of the terminal window. When the installation is complete, a message appears (as shown below) telling you that the package has been installed.
You can use the df command to check capacity and use of the different file systems configured on your Linux computer. If we channel its output into the grep command and search for “gimp”, we isolate package entry we just installed.
We type the following:
df | grep gimp
This shows us that the snap package was mounted as if it were a file system. The mount point is in the snap directory here: / snap / gimp / 252. The “252” is the version number for this version of gimp.
RELATED: How to use the grep command on Linux
The file system is listed as: / dev / loop18. Looped device files are used to make regular files accessible as block devices. They are generally used to mount file systems in disk images. In this case, they mount the SquashFS file system in the snap package. The “18” means that this is the 18th device / dev / loop file used on this Linux computer.
We can use the df command to quickly verify this. We will use the -t (type) option to limit the output to SquashFS file types only.
We type the following:
df -t squashfs
Mounted SquashFS file systems are listed. A device file / dev / loop manages each of them, and there are 18 of them.
Each file system is mounted on a directory in the / snap directory. However, this does not mean that 18 different snap packages are installed on this computer. It is an Ubuntu distribution, so some snap packages are installed right out of the box, and we just installed another one.
In addition, when you install snapd, it installs some basic snap packages to manage the needs of other snap packages.
We can use the snap list command, as shown below, to list the installed snap packages:
The output was a bit wide, so the end of the lists is shown below.
Here is the complete list:
Name Version Rev Tracking Publisher Notes
nucleus 16-2.43.3 8689 stable canonical nucleus *
core18 20200124 1668 stable canonical base *
gimp 2.10.18 252 stable snapcrafters –
gnome-3-26-1604 126.96.36.19991114 98 stable /… canonical * –
gnome-3-28-1804 3.28.0-16-g27c9498.27c9498 116 canonical stable * –
gnome-calculator 3.34.1 + git1.d34dc842 544 stable /… canonical * –
gnome-characters v3.32.1 + git3.b9120df 399 stable /… canonical * –
gnome-logs 3.34.0 81 stable /… canonical * –
gnome-system-monitor 3.32.1-3-g0ea89b4922 127 stable /… canonical * –
gtk-common-themes 0.1-28-g1503258 1440 stable /… canonical * –
As you can see, 10 snap packages are installed, not 18. However, these 10 packages gave birth to the 18 SquashFS file systems. The columns in the table are fairly self-explanatory, but here are some clarifications:
Last name: Name of the installed snapshot package.
Version: The software version number in the snap package.
Tower: Revision number of the snapshot package.
followed: Channel on which this snapshot package monitors for updates. They are four:
Stable: The default channel. As the name suggests, this channel contains the most stable packages.
Candidate: This channel is less stable, but very close because it contains a candidate version software, which is complete in code. It goes through the final tests before going to the stable channel.
Beta: This channel has a late development cycle quality, but it is not guaranteed to be stable.
Edge: For the first build testers. You should not use this system for important work or on a production computer. Here are dragons!
Editor: The person, company, or organization that published the snapshot package. If it was a verified editor (and your terminal window supports Unicode), you’ll see a green check mark next to the publisher’s name. If it cannot display a check mark, you will see an asterisk (*).
Remarks: Any comments or additional information will appear here.
You can use the info option to get a description of a snap package.
To do this, we type the following:
snap info gtk-common-themes
We can see which channel the package follows, and the software version in the instant packages in each of the four channels. In most cases, you must stay on the stable channel.
A snapshot package checks four times a day to see if a new version of the software is available from the channel it is watching or “following”. If you want to change the channel followed by a snapshot package, you can use the refresh and –channel options.
To do this, we type the following:
sudo snap refresh gtk-common-themes –channel = beta
If a newer version of the software was available, it would be installed, but this was not the case here. However, the snap package now follows the beta channel. As soon as a new beta version is released, it is automatically downloaded and upgraded.
You can use the –list option to check if updates are available for any of the snapshot packages installed on your computer.
To do this, we type the following:
sudo snap refresh – list
You will be notified if any of the channels followed by the snapshot packages on your computer contain newer software versions.
If a newer version of the software is available, you can use the refresh option, as shown below, to manually force a refresh:
sudo snap refresh gtk-common-themes
Removing a snap package
To uninstall a snapshot package, you can use the delete option, as shown below:
sudo snap remove gimp
The snap cheat sheet
Using snap packages is quite simple, but we have compiled a list of a few commands that will help you:
To find a package: snap find package_name
To install a package: sudo snap install package_name
To see all installed packages: hanging list
For information on a single package: snap info package_name
To change the channel, a package follows the updates: sudo snap refresh package_name –channel = channel_name
To see if the updates are ready for all installed packages: sudo snap refresh – list
To manually update a package: sudo snap refresh package_name
To uninstall a package: sudo snap remove package_name