What is Snap?
Snap is a software deployment and packaging system developed for operating systems by Canonical that applies the Linux Kernel. Several packages, known as snaps, and the tool to use them, called snapd, work around a variety of Linux distributions and permit the developers of upstream software for distributing their applications to users directly. Snap is a self-contained application executing in a sandbox along with mediated access to a host system. Originally, Snap was published for cloud applications but later was ported to implement for desktop applications and IoT devices too.
Functionality of Snap
Common Linux packages
Snap is a self-contained package that implements a variety of Linux distributions. It is unlike the classical approaches to Linux package management which need particularly adapted packages for all Linux distributions.
The file format of Snap is an individual compressed file system with the SquashFS format using the .snap extension. This file system includes the software, libraries it relies on, and informative metadata. This metadata is developed by snapd for setting up a properly shaped protected sandbox for that software. The Snap is positioned by the host operating system and decompressed when the files are utilized after installation. However, it has a benefit that snaps utilize less disk space, it means a few large applications begin slower.
An important distinction between Snap and other common packaging formats of Linux like Flatpak is that Snap provides its support for any class of Linux software like IoT applications, server tools, desktop applications, and even system services like the printer driver stack. For ensuring it, Snap depends on the system for several features like executing socket-activated system services inside a Snap. It leads to Snap working best just on distributions that can acquire that init system.
It permits developers to release their snap-packaged software. Every application uploaded to the Snap Store goes through automatic testing such as a malware scan. Although, Snap doesn't catch every issue. In a case in 2018 May, two Applications by a similar developer were detected for containing cryptocurrency miners which were executed in the background at the time of the application execution.
Canonical deleted the applications through the Snap Store and ported Snap's ownership to a third party which re-released the Snaps without any miner present when this problem was detected. However, the sandbox of the Snap decreases the effect of a malicious application, Canonical suggests users install only Snaps from those publishers who are trusted by the user.
In a Snap, applications execute in a container along with limited access to a host system. Users can provide application access to extra features like recording video, accessing USB devices, and recording audio using interfaces. These interfaces negotiate with regular APIs of Linux so that applications can operate in a sandbox without requiring to be re-written.
Also, the desktop applications can utilize the XDG Desktop Portals, which is a standardized API made by the Flatpak project to provide sandbox desktop software access to the host resources. Often, these portals give a better User experience than the native Linux APIs as they ask the user for their permission to resources like a webcam during the time the application applies them. The downside is that the toolkits and applications require to be re-written for using these fresh APIs.
Several popular themes are packaged via Snap developers but a few themes aren't yet supported and uncommon themes need to be manually installed. If a theme isn't present as a Snap package, then users need to resort to selecting the best theme available. Work is continuing to make it efficient for third parties for packaging themes within a Snap and for automatically installing uncommon themes of the system.
Atomic and automatic updates
Snapd inspects for available updates of every Snap and installs them inside the background with the help of the atomic updates many times a day. Updates can be turned back and applied delta encoding for reducing their download size.
In parallel, publishers can update and release more than one release of their software using channels. All channels have a specific risk and track which represent the stability and version of the software published on that channel. By default, Snap uses the channel, i.e., latest/stable which automatically will update to new versions of the software when they are available during the installation of an application. Publishers can make extra channels for providing users the possibility to link with specific versions of their software.
They can also take updates for up to 60 days. Updates are automatically metered or disabled connections. Several users have voiced their claims about the insufficient option to completely turn off the automatic updates even with these types of controls.
For developers, it is a tool for packaging their programs in the format of Snap. It executes on any distribution of Linux supported by Snap, Microsoft Windows, and macOS. Snapcraft constructs the packages using multipass in a virtual machine to ensure the output of a construct is the same, despite which operating system or distribution it is constructed on.
Adoption of Snap
Initially, Snap only supported the distribution of all-Snap Ubuntu Core but it was ported to a huge variety of Linux distributions for becoming a format for common Linux packages in June 2016. Snap needs systemd which is present in almost all, but not all, Linux distros. Other Unix-like systems (like FreeBSD) aren't supported. Chrome operating system doesn't directly support Snap, only from Linux distributions installed in it that are supporting Snap like Gallium operating system.
Several Linux distros support Snap out of the box like Ubuntu (and also its derivatives like Xubuntu and Kubuntu), Li-f-e, Solus, KDE Neon, Zorin OS, and Manjaro. Also, Snap is available for several other distributions like OpenSUSE, Red Hat Enterprise Linux, Raspbian, Pop! OS, Parrot Security OS, Open Embedded, Linux Mint, Kali Linux, GalliumOS, Fedora, Elementary OS, Debian, and CentOS.
Canonical decided to shift the Chromium web browser into Ubuntu releases in the future to a Snap from an APT package in 2019. They said that snap made it much more efficient for supporting Chromium on every supported release of Ubuntu. It permitted them to concentrate on engineering resources on other Ubuntu desktop parts. As an outcome of this determination, Ubuntu derivatives like Linux Mint had to select between switching to the snapped release of Chromium or managing their Chromium package version managed by Canonical.
Snap package on Ubuntu
Snap defines both the Snap installation file and the Snap command. A Snap collects an application and each of its dependent into a single compressed file. These dependents maybe database or web server, library files, or anything else the application must need to launch and execute.
Snaps make installations easier because they ignore the dependency hell heartache. It is what appears when a fresh application cannot execute either because a needed resource is not available, and it is a wrong release, or its installation overwrites files needed by previous applications so they cannot execute.
We may assume a snap to be uncompressed and files extracted at the installation time. It is however at run time when the snap file is positioned on a block loop device. It permits the internal SquashFS file system of the file to be accessed. The application is Run in a ring-fenced and encapsulated way, so its files cannot interfere with those that are present on our system. We can even install more than one version of a similar application and they would not fight or cross-pollinate amongst themselves.
So, Canonical has substituted the Ubuntu software application with a release that by default installs Snaps with Focal Fossa.
Ubuntu Software Center
To list the file systems, i.e., SquashFS mounted on our computer, we can apply the df command. We will apply the -t option for restricting the result to the file systems we are interested in.
The command is as follows:
Then, we will use a command for listing installed snaps:
There are two different snaps corresponding to the GNOME desktop, two corresponding to the core functionality of Snap, one for Snap Store, and one for GTK themes. Also, the snap-store application is a Snap.
Note: The application is Ubuntu Software if we execute the command, i.e., snap-store in the terminal window.
We would usually execute the Ubuntu Software by selecting its icon. We are launching it using the command line for demonstrating that below the surface, it is now the snap-store software:
Ubuntu Software looks just as we would think. We can find every software we previously could.
Let's find and install the application, i.e., "sqlitebrowser". The output screen displays the information of the applications. We can choose the install option for installing the application.
If we did not know, we would not suspect the modifications below the hood. We need to scroll down and we will find see a few new and snap-specific information.
The information list gives the below details:
The channel could be one of the below:
We can check the installed snap list after the installation process is completed by again using the following command: