The Linux snap command: install universal applications

What's Snap?

Snap is an application packaging and distribution system developed by Canonical, the company behind Ubuntu. Its main objective is to offer universal applications that can be run in any Linux distribution without worrying about the specific units of each system. Each Snap package includes the application binary, all its libraries and necessary resources, encapsulated in an isolated environment called sandbox. This approach eliminates the famous hell of dependencies and allows users to get the same version of a program both in Ubuntu, Fedora, Arch or openSUSE, provided the snapd demon is installed and functioning.

Advantages of using Snap

  • Universality: the same snap works in multiple disters.
  • Automatic and transparent updates: snapd regularly reviews more recent versions and applies them without user intervention.
  • Simple Rollback: If an update causes problems, you can return to the previous version with a single command.
  • Security insulation: each snap is run on a sandbox that limits your access to the system and other snaps.
  • Conflict reduction: by including their own dependencies, they do not interfere with traditional manager packages (apt, dnf, pacman).

Snap installation in different distributions

In Ubuntu and its derivatives, snapd comes pre-installed from version 16.04 LTS. In other distributions, it is enough to use your own package manager:

  • In Debian:sudo apt update && sudo apt install snapd
  • In Fedora:sudo dnf install snapdfollowed bysudo systemctl enable --now snapd.socket
  • In Arch Linux:sudo pacman -S snapdand then enable the socket.
  • In openSUSE:sudo zypper install snapdand activate the service.

After installing, it is recommended to restart or log in again so that the route/snap/binstay in thePATHof the user.

Basic command of Snap

  • snap find <texto>search for applications in the Snap Store repository.
  • snap install <paquete>download and install the indicated snap.
  • snap listdisplays all the installed snaps and their versions.
  • snap refresh <paquete>updates a specific snap; without arguments updates all.
  • snap remove <paquete>removes the snap from the system.
  • snap revert <paquete>back to the previous version of the snap.
  • snap info <paquete>shows details such as version, editor and permissions.

Practical example: install an application

Suppose we want to install the Visual Studio Code code editor. The process is as simple as:

sudo snap install code --classic

The -classic flag allows the snap to access the entire file system, necessary for VS Code to function as a traditional program. After installation, we can run it from the application menu or by typingcodeAt the terminal.

Another popular example is the Slack messaging client:

sudo snap install slack

In this case it is not required -classic because the snap is confined and still offers all the expected functionality.

Snap Package Updating and Disposal

The updates are managed automatically in the background, but the user can force a review with:

sudo snap refresh

If an application is to be withdrawn, it is sufficient to:

sudo snap remove 

By removing, snapd retains a cache of previous versions for a short period, allowing them to be quickly restored if you change your mind.

Safety and performance considerations

Although the isolation of the snaps increases security, it also implies a slight overhead in the start of the application, as each snap must mount its own squashfs file system. However, in modern hardware this delay is imperceptible for most users. In addition, snaps can occupy more disk space because they include their dependencies; however, the deduplication of common layers will partially mitigate this effect.

From the point of view of confidence, the Snap Store allows anyone to post a snap, but Canonical reviews and signs the official snaps; it is recommended to check the editor and the permissions before installing third-party snaps.

Conclusion

The snap command has become an essential tool for those looking for a simple and consistent way to install Linux applications, regardless of distribution. Its model of universal packages, automatic updates and security insulation positions it as a solid alternative to traditional package managers. If you have not yet tried it, install snapd and try some popular program like Visual Studio Code or Slack is the best way to experience your first-hand benefits.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish