The snap command in Linux: install universal applications

What is Snap?

Snap is a packaging and distribution system for applications developed by Canonical, the company behind Ubuntu. Its main goal is to provide universal applications that can run on any Linux distribution without worrying about each system’s specific dependencies. Each Snap package includes the application binary, all its libraries and necessary resources, encapsulated in an isolated environment called a sandbox. This approach eliminates the infamous dependency hell and allows users to obtain the same version of a program on Ubuntu, Fedora, Arch, or openSUSE, as long as the snapd daemon is installed and running.

Advantages of Using Snap

  • Universality: a single snap works on multiple distros.
  • Automatic and transparent updates: snapd periodically checks for newer versions and applies them without user intervention.
  • Easy rollback: if an update causes problems, you can revert to the previous version with a single command.
  • Security isolation: each snap runs in a sandbox that limits its access to the system and other snaps.
  • Reduced conflicts: by including their own dependencies, they do not interfere with packages from the traditional manager (apt, dnf, pacman).

Installing Snap on Different Distributions

On Ubuntu and its derivatives, snapd comes preinstalled from version 16.04 LTS. On other distributions, you can use the distro’s own package manager:

  • On Debian: sudo apt update && sudo apt install snapd
  • On Fedora: sudo dnf install snapd followed by sudo systemctl enable --now snapd.socket
  • On Arch Linux: sudo pacman -S snapd and then enable the socket.
  • On openSUSE: sudo zypper install snapd and activate the service.

After installing, it is recommended to log out and back in (or reboot) so that the /snap/bin directory is added to the user’s PATH.

Basic Snap Commands

  • snap find <texto> searches for applications in the Snap Store.
  • snap install <paquete> downloads and installs the specified snap.
  • snap list shows all installed snaps and their versions.
  • snap refresh <paquete> updates a specific snap; without arguments it updates all.
  • snap remove <paquete> removes the snap from the system.
  • snap revert <paquete> returns to the previous version of the snap.
  • snap info <paquete> displays details such as version, publisher, and permissions.

Practical Example: Installing an Application

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

sudo snap install code --classic

The --classic flag allows the snap to access the entire filesystem, which is necessary for VS Code to work like a traditional program. After installation, you can run it from the applications menu or by typing code in the terminal.

Another popular example is the Slack messaging client:

sudo snap install slack

In this case --classic is not required because the snap is confined yet still provides all the expected functionality.

Updating and Removing Snap Packages

Updates are managed automatically in the background, but the user can force a check with:

sudo snap refresh

If you wish to remove an application, simply run:

sudo snap remove 

When removing, snapd keeps a cache of previous versions for a short period, allowing quick restoration if you change your mind.

Security and Performance Considerations

Although the isolation of snaps increases security, it also introduces a slight overhead at application startup, as each snap must mount its own squashfs filesystem. However, on modern hardware this delay is imperceptible for most users. Additionally, snaps may occupy more disk space because they include their dependencies; nevertheless, deduplication of common layers mitigates this effect partially.

From a trust perspective, the Snap Store allows anyone to publish a snap, but Canonical reviews and signs the official snaps; it is advisable to verify the publisher and permissions before installing third‑party snaps.

Conclusion

The snap command has become an essential tool for those seeking a simple and consistent way to install applications on Linux, regardless of the distribution. Its model of universal packages, automatic updates, and security isolation positions it as a solid alternative to traditional package managers. If you haven’t tried it yet, installing snapd and experimenting with a popular program like Visual Studio Code or Slack is the best way to experience its benefits firsthand.

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .