Chapter 3: Snap Packages


Snap is a sandboxed package format created by Canonical (the company behind Ubuntu). A Snap package bundles an application with all its dependencies into a self-contained unit. This means the app runs the same way on any Linux distribution that has snapd installed, and updates happen automatically in the background.


How Snap Works

The snapd daemon runs in the background and manages all Snap packages. When you install a Snap, snapd downloads a compressed filesystem image (a .snap file) and mounts it as a loop device at /snap/package-name/. The app runs from this read-only mount point.

Snap packages are distributed through the Snap Store, Canonical’s hosted app store at snapcraft.io.

On Ubuntu 16.04 and later, snapd is pre-installed. On other distributions:

# Debian / older Ubuntu
sudo apt install snapd

# Fedora
sudo dnf install snapd

Essential Commands

Finding and installing

snap find keyword                      # search the Snap Store
snap info package-name                 # show details, channels, version
sudo snap install package-name         # install latest stable release
sudo snap install package-name --channel=beta   # install from a specific channel

Managing installed snaps

snap list                              # list all installed snaps
sudo snap refresh                      # update all snaps
sudo snap refresh package-name        # update one snap
sudo snap remove package-name         # uninstall a snap

Channels: Stable, Candidate, Beta, Edge

Every Snap is published to one or more channels that represent different stability levels:

Channel Stability Typical use
stable Production-ready Default for most users
candidate Pre-release, nearly stable Testing before stable release
beta Active development Early adopters
edge Latest commit, may be broken Developers only

Switch a snap between channels:

sudo snap switch package-name --channel=beta
sudo snap refresh package-name

Classic vs Strict Confinement

Snap packages use confinement to limit what an app can access:

sudo snap install code --classic        # VS Code requires classic confinement

When a snap needs classic confinement, the Snap Store page or snap info output will say so.


Where Snaps Live

/snap/                   # mount points for installed snaps
/var/snap/               # snap data directories (settings, caches)
/snap/bin/               # symlinks to snap executables

Each snap version is kept separately under /snap/package-name/, so rollback is possible:

sudo snap revert package-name          # roll back to the previous version

Controlling Automatic Updates

Snaps update automatically. To check when updates were last applied:

snap refresh --time                    # show next scheduled refresh

To hold a snap at its current version:

sudo snap refresh --hold=forever package-name

You can also configure a refresh schedule system-wide:

sudo snap set system refresh.schedule="00:00-04:00"

Trade-offs

Snaps offer real benefits: sandboxing, automatic updates, and cross-distribution compatibility. But they come with trade-offs worth understanding:

Benefit Trade-off
Self-contained, no dependency conflicts Larger download and disk size
Automatic background updates Less control over when updates happen
Sandboxed for security May need explicit permission grants for some access
Works on any distro with snapd Startup time can be slower than native packages
Easy rollback Loop mounts add clutter to df output

For GUI applications where sandboxing and convenience matter, Snap is a good choice. For CLI developer tools where startup speed matters, a native apt package or Flatpak may be preferable.


Key Takeaways


← Chapter 2: apt and .deb Packages Table of Contents Chapter 4: Flatpak →