Where to start First steps track · 15 stages
Linux Labs

snap — Ubuntu packages

4 min Ubuntu 24.04 · snapd

Ubuntu's second package format with auto-update; snap revert rolls back to the previous version, kept by snap itself.

Cheat sheet

7 commands Printable version
  • snap list installed packages
  • sudo snap install nginx install a package
  • sudo snap refresh update all packages
  • sudo snap refresh --hold nginx pause auto-updates for a package
  • sudo snap revert nginx roll back to the previous version
  • snap services services of all snap packages
  • sudo snap remove --purge nginx remove along with its data

Overview

snap is Ubuntu's second package format (alongside apt): self-contained apps with auto-update, isolated in a sandbox. Often used to install newer versions (certbot, some utilities, IDEs).

bash
snap list                         # installed snap packages (+ version, channel)
snap find keyword                 # search the Store
snap info package                 # details and available channels (tracks)

Options

5

A package is installed inside a sandbox (confinement): access to files outside $HOME and to devices must be granted explicitly through interfaces (plug/slot), otherwise snap can't see them even if the process runs as root. --classic removes the sandbox entirely — use it only for packages that ask for it themselves (IDEs, build tools), never by default.

bash
snap connections nginx            # which interfaces are connected
sudo snap connect nginx:removable-media   # grant access explicitly
sudo snap set system refresh.retain=2     # keep fewer old revisions
Option What it does Example
--classic Install without confinement — full system access, like a regular package. dangerous snap install code --classic
--channel CHANNEL Install or switch the package to a different channel (stable/candidate/beta/edge). snap install nginx --channel=edge
--hold Pause automatic updates for the package (indefinitely if no duration is given). snap refresh --hold nginx
--purge When removing the package, also erase its data, with no way to revert. dangerous snap remove --purge nginx
--revision N Install a specific revision instead of the latest one in the channel. snap install nginx --revision=123

Nothing found. Try a shorter query.

Recipes

2

Commands

bash
sudo snap install package         # install (stable channel)
sudo snap install package --classic   # full access (IDEs/tools, no sandbox)
sudo snap install package --channel=edge   # from a different channel
sudo snap refresh                 # update every snap
sudo snap refresh package         # update one
sudo snap refresh --hold package  # pause auto-updates for the package
sudo snap revert package          # roll back to the previous version (snap keeps it!)
sudo snap remove package          # remove it
sudo snap remove --purge package  # + remove its data
snap changes                      # snapd operation history
sudo snap install package --revision=123   # a specific revision

Snap services

bash
snap services                     # services of all snap packages and their state
sudo snap start package.svc       # start the package's service
sudo snap stop package.svc        # stop the package's service
sudo snap restart package.svc     # restart the package's service
sudo snap logs package            # the service's logs
sudo snap info package            # available channels: stable/candidate/beta/edge

Troubleshooting

5

The package installs slowly / is huge

Snap bundles its dependencies (heavier than apt) — this is normal. For lightweight CLI tools, apt is often a better choice.

Snap can't see files outside $HOME

The sandbox (confinement) restricts access. snap connections package, then sudo snap connect package:removable-media (or the needed plug). For full access — --classic (if the package supports it).

It updated and broke

sudo snap revert package rolls back to the previous version (snap keeps it). To pin against auto-updates: sudo snap refresh --hold package.

Is this apt or snap?

which cmd, snap list | grep cmd, dpkg -S $(which cmd) (see which, apt). Sometimes a tool exists in both — pick the source deliberately.

Old revisions take up space

snap keeps past revisions. snap list --all; reduce how many are kept: sudo snap set system refresh.retain=2.

See also

  • apt — Installing, updating, and removing packages on Debian/Ubuntu; apt and dpkg.
Loading…