Javatpoint Logo
Javatpoint Logo

Ubuntu Snap

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

Ubuntu 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.

Snap Store

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.

Configurable Sandbox

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.

  • Also, the Snap sandbox supports sharing Unix sockets and data between Snaps.
  • It is often used for sharing common application frameworks and libraries between Snaps to decrease the size of snaps by ignoring duplication.
  • The sandbox of Snap heavily depends on the AppArmor Linux Security Module through the upstream Linux Kernel.
  • The snap sandbox is less secure if another big Linux Security Module (or LSM) is activated because a major LSM can be enabled at the same.
  • As an outcome, on distributions like Fedora which by default enable SELinux, the sandbox of Snap is heavily degraded.
  • However, Canonical is operating with several other companies and developers for making it possible for more than one LSM to execute at the same time.
  • The Snap sandbox avoids snapped desktop software from accessing the host operating system's themes to block compatibility issues.
  • Also, it requires to be packaged in an isolated Snap for using a theme for Snaps.

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.

  • If the publishers publish a new big release in a fresh channel, then users can update to any next release manually when they select.
  • Atomic updates could be turned off with some hacks.
  • There are also several ways for configuring updates to suit specific requirements.
  • Users can select to stay on a particular major release of the software by describing the channel.
  • Also, they can construct the update interval for having time to check updates manually.
  • For example, the following command will inspect the update over the last Friday from 23:00 to 01:00

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.

Snapcraft

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.

Snapcraft provides its support for multiple programming languages (like Rust, C/C++, Python, JavaScript, Java, and Go) and build tools. Also, it permits importing the metadata of the applications from more than one source like shell scripts, git, AppStream, and setup.py files.

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.

  • Several companies of the Desktop software development release their software within the Snap Store including Spotify, Mozilla, Microsoft (for Linux releases of PowerShell, Skype, Visual Studio Code, .NET Core 3.1), KDE, JetBrains, and Google.
  • Also, Snap is used in IoT environments which are ranging from consumer-facing products to satellite communication networks and enterprise device management gateways.
  • Snap is finally used by server application developers like Travis CI, Nextcloud, Kata Containers, and InfluxDB.

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.

  • The installation file-s downside is bigger as compared to the classical DEB files.
  • Also, they use more real estate of a hard drive.
  • All applications that require specific resources install their copy with Snaps.
  • It is not the most dynamic use of the hard drive space.
  • However, hard drives are getting cheaper and bigger traditionalists still resist the extravagance of all applications executing in its mini-container.
  • Also, launching applications is slower.
  • Also, Snaps have been criticized for not pursuing the desktop theme and their automatic updates.
  • A few people are suspicious because snaps are not necessarily created by the software authors. Hence, they do not examine them to be 100% official.

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:


Ubuntu Snap

Then, we will use a command for listing installed snaps:


Ubuntu Snap

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 Snap

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:

Ubuntu Snap
  • Channel: It is a channel through which the installation will drag the application.
  • License: It specifies the types of licenses.
  • Version: It specifies the types of versions.
  • Source: It is the source through which the Snap would be downloaded (the Snapcraft snap store of Canonical is io)
  • Developer: Developers are the people who made the Snap or who wrote an application.
  • Download size: It specifies the snap file's size.

The channel could be one of the below:

Ubuntu Snap
  • Candidate: It is less stable. Although, it is very close to the stable channel because it includes the release candidate level software.
  • Stable: It is the default channel that includes the most dependable and stable packages.
  • Edge: It is for the inquisitive and early build testers. We should not use it for anything important.
  • Beta: It is late-development-cycle quality, however not assured to be stable.

We can check the installed snap list after the installation process is completed by again using the following command:


Ubuntu Snap





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA