How To Install Snap

How To Install Snap

Reading time1 min
#Linux#OpenSource#Software#Snap#Snapcraft#PackageManagement

Installing Snap on Linux: Practical Guide for Modern Systems

Snap packages, maintained by Canonical, standardize application deployment across diverse Linux distributions. Unlike classic .deb or .rpm packages, Snaps are bundled with their dependencies and execute in isolated environments, minimizing compatibility headaches but introducing some runtime overhead. Snap’s core process, snapd, manages snapshots, rollback, and automatic updates behind the scenes.

Below: key installation flows, trade-offs, and tangible troubleshooting steps gleaned from real deployments (tested with Ubuntu 22.04, Fedora 39, Arch 2024.01, openSUSE Leap 15.5).


Preliminary: Is Snapd Already Active?

The snapd daemon ships by default on recent Ubuntu images but not on all derivatives or other distributions. Verify presence and state:

snap version

Typical positive output:

snap     2.61.3
snapd    2.61.3
series   16
ubuntu   22.04
kernel   5.15.0-84-generic

No output or command not found? Proceed below.


Install Steps by Distribution

Ubuntu, Debian, Mint

Update indexes, deploy snapd, and confirm socket activation:

sudo apt update
sudo apt install snapd
sudo systemctl enable --now snapd.socket

Note: For Ubuntu Server, snapd is installed by default post-22.04 LTS, but the socket occasionally needs manual start after custom minimal installations.

Fedora 35+ / RHEL 9+ / Rocky/Alma

sudo dnf install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap   # Required for classic snap support (e.g., VSCode)

Gotcha: SELinux can interfere with snap's mountpoints. If snap install fails silently, audit logs for AVC denials.

Arch Linux / Manjaro

sudo pacman -S snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

Known Issue: Kernel modules (notably squashfs) must be present—lsmod | grep squashfs. Absent? Most likely, you’re running a stripped-down kernel.

openSUSE (Leap/Tumbleweed)

sudo zypper install snapd
sudo systemctl enable --now snapd
sudo ln -s /var/lib/snapd/snap /snap

Validation & Sanity Check

After installation, ensure daemon is functional:

snap version
systemctl status snapd

Example error during misconfiguration:

cannot communicate with server: Post http://localhost/v2/snaps/hello-world: dial unix /run/snapd.socket: connect: no such file or directory

This usually means the socket isn’t started, or the service is masked. Unmask with:

sudo systemctl unmask snapd
sudo systemctl restart snapd

Deploying Your First Snap: hello-world

Sanity test with a non-critical package:

sudo snap install hello-world
hello-world

Output should mirror:

Hello World!
This is a Snap test.

If failures occur, check /var/log/syslog or journalctl -u snapd for details. E.g., lack of FUSE or squashfs will be explicit in logs.


Non-Obvious Tips and Caveats

  • Service Autostart: On some servers, systemd’s dependency order can delay snap mounts until after first login or network-online.target. Consider a manual sudo systemctl restart snapd after upgrades.
  • Storage Location: All snaps and revisions are stored under /var/lib/snapd/snaps/. Heavy snap usage impacts root partition. Periodically run snap list --all and sudo snap remove --revision=<rev> for cleanup.
  • AppArmor/SELinux: Snapd leverages AppArmor (“Enforce”) on Ubuntu and falls back to seccomp profile elsewhere. Some legacy software (e.g., Wine, CUDA) may refuse to run sandboxed—prefer .deb or native sources in such cases.

Summary Table: Snapd Install Commands (2024 Editions)

DistroInstall Command
Ubuntu/Debiansudo apt update && sudo apt install snapd && sudo systemctl enable --now snapd.socket
Fedora/RHELsudo dnf install snapd && sudo systemctl enable --now snapd.socket && sudo ln -s /var/lib/snapd/snap /snap
Arch/Manjarosudo pacman -S snapd && sudo systemctl enable --now snapd.socket && sudo ln -s /var/lib/snapd/snap /snap
openSUSEsudo zypper install snapd && sudo systemctl enable --now snapd && sudo ln -s /var/lib/snapd/snap /snap

Final Notes

For deployments across heterogeneous fleets, Snap offers consistent results—but comes with disk and memory overhead, and not all upstream projects publish official Snaps. Alternative: consider Flatpak for GUI applications, or stick to native .deb/.rpm packaging for highly stateful workloads.

Reference: Official Snap Documentation

If encountering persistent failures, attach journalctl -xeu snapd output to bug reports for proper triage.