A snap is a bundle of an app and its dependencies that works without modification across many different Linux distributions. Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.
The following sections provide a basic overview of using snaps, from installation to management and manipulation.
|Install snapd||Discover and find snaps|
|Learn about a snap||Install a snap|
|Run apps from snaps||Where snaps store data|
|List installed snaps||Update snaps|
|Understanding versions||Create and restore a snapshot|
|Revert to a previous snap revision||Remove a snap|
The snapd daemon manages the snap environment on the local system. Its installation will include the snap tool for interacting with snaps. You can check both are installed by attempting to run
snap version on the command line:
$ snap version snap 2.45 snapd 2.45 series 16 ubuntu 20.04 kernel 5.4.0-31-generic
If all is well, version numbers for the main system components will be output, as shown above, albeit with potentially different versions and Linux distribution identifier.
If the snap command is not found, or if the command takes a while to respond before reporting that snapd is unavailable, make sure snapd is properly installed before continuing.
Find a snap
With snapd installed, snaps can be discovered, searched for, and installed from the Snap Store, from the Snap Store desktop app, and directly from the command line. For example, the following command returns a list of media players:
$ snap find "media player" Name Version Developer Notes Summary (...) vlc 3.0.4 videolan✓ - The ultimate media player. mpv 0.26.0 casept - a free, open source, and cross-platform media player. (...)
✓ alongside videolan in the above output indicates that the snap publisher has been verified.
Learn about a snap
The snap info command makes it easy to find more details about a specific snap. These details include what a snap does, who publishes it, the command(s) it provides and which channel versions are available for installation:
$ snap info vlc name: vlc summary: The ultimate media player publisher: VideoLAN✓ contact: https://www.videolan.org/support/ description: | VLC is the VideoLAN project's media player. (...) snap-id: RT9mcUhVsRYrDLG8qnvGiy26NKvv6Qkd commands: - vlc channels: stable: 3.0.0 (158) 197MB - candidate: 3.0.0 (158) 197MB - beta: 3.0.0-5-g407d4ba (160) 197MB - edge: 4.0.0-dev-1218-g201542f (159) 197MB
--verbose option to info to retrieve more details on the snap, including expanded notes and details on which base the snap uses.
Install a snap
Installing a snap is straightforward:
$ sudo snap install vlc
Channels are an important snap concept. They define which release of a snap is installed and tracked for updates. The stable channel is used by default, but opting to install from a different channel is easily accomplished:
$ sudo snap install --channel=edge vlc
After installation, the channel being tracked can be changed with:
$ sudo snap switch --channel=stable vlc
The sudo command ensures the command following it is executed as the root administrative user. While not a requirement for using snaps, creating an Ubuntu One/SSO account, and authenticating once with
snap login <email-address>, removes the need to use sudo with snap commands.
Run apps and commands from snaps
A snap’s installed applications can be found under
/snap/bin, and subsequently, often added to $PATH. This makes commands directly accessible from the command line.
For example, the command installed via the VLC snap is simply vlc:
$ which vlc /snap/bin/vlc
If executing a command directly doesn’t work, try prefixing it with the /snap/bin path:
Where snaps store data
Most snaps use strict confinement to isolate both their execution environments and their data from your system (see Snap Confinement for further details). A confined snap that needs user-access to files will most likely use the home interface to bridge this confinement gap, allowing you to save and load files from your home directory automatically.
You can see whether the home interface is being used in the output to
snap connections <snap name>:
$ snap connections nethack Interface Plug Slot Notes home nethack:home :home -
Regardless of whether the home interface is used or not, a snap can also store user data, such as a database or configuration files, within its own directory under $HOME/snap. Data within this snap-specific directory is stored in one of two further directories, depending on whether the data needs to be tied to a specific release, or whether it can be used across multiple releases.
Data for a specific release is stored within a directory named after the revision of a release. This is a numeric value, such as
56. The data for each specific revision is often copied from one release to the next, so that reverting from one revision to a previous revision will restore a working configuration, for instance. The snap directory also contains a symbolic link called
current that points to the snap revision currently active.
Data that can be shared across releases is stored in a directory called
common, and might include image or audio caches, or a database. This data is not copied between releases.
For more details on where snaps store their data, see Data locations.
List installed snaps
snap list to show a list of snaps installed on your system:
$ snap list Name Version Rev Tracking Publisher Notes core 16-2.35.1 5419 beta canonical✓ core spotify 126.96.36.1993 19 stable spotify✓ - vlc 3.0.4 555 stable videolan✓ -
Some snaps, such as core listed above, are installed by automatically by snapd to satisfy the requirements of other snaps.
Update an installed snap
Snaps are updated automatically. However, to manually check for updates, use the following command:
$ sudo snap refresh vlc
The above will check the channel being tracked by the snap. If a newer version of the snap is available, it will be downloaded and installed.
Changing the channel being tracked and refreshing the snap can be accomplished with a single command:
$ sudo snap refresh --channel=beta vlc
Updates are automatically installed within 6 hours of a revision being made to a tracked channel, keeping most systems up-to-date. This schedule can be tuned via configuration options.
Versions and revisions
Versions and revisions convey different details about one specific release of a snap:
- Version : the version of the software being packaged, as assigned by the developers
- Revision: the sequence number assigned by the store when the snap file was uploaded
The version is a string that was assigned to a project by its developers, according to their development practices. It tells the user what content to expect from a snap. The revision is an automatic number assigned by the Snap store, giving the snap a unique identity within the channel.
Neither the version nor the revision enforce an order of release. The local system will simply attempt to install whatever snap is recommended by the publisher in the channel being tracked.
Revert to a previously used snap
A snap may be reverted to a previously used revision with the
snap revert command:
$ sudo snap revert vlc vlc reverted to 3.0.5-1
This operation will revert both the snap revision and the configuration data associated with the software. If the previously used revision of the snap is from a different channel, that snap will be installed but the channel being tracked won’t change.
User data, such as data generated by the snap and stored in a database, is often stored in a common directory and will not be reverted. See Data locations for more details on what information is stored and where.
A snap won’t automatically update to a version previously reverted from, and the output from
snap refresh will continue to state All snaps up to date. A reverted snap will be automatically updated when a new and different revision is made available by the publisher.
However, explicitly adding the snap name to
snap refresh will update the snap, regardless of whether the latest revision was previously reverted from or not:
$ snap list --all vlc Name Version Rev Tracking Publisher Notes vlc 3.0.5-1 768 stable videolan✓ - vlc 3.0.6 770 stable videolan✓ disabled $ sudo snap refresh All snaps up to date. $ sudo snap refresh vlc vlc 3.0.6 from VideoLAN✓ refreshed
On an Ubuntu Core system, such as Ubuntu Core 18 and Ubuntu Core 16, reverting twice will work too. This is because snapd attempts to keep three revisions of a snap: the most recently installed plus the two previous installations. On classic systems like Ubuntu 18.04 LTS or Ubuntu 16.04 LTS, two revisions are retained by default. This behaviour can be modified with the refresh.retain system option.
List all available revisions
The following command lists all revisions available for all installed snaps, and also highlights which particular revisions are disabled at the moment:
snap list --all Name Version Rev Tracking Publisher Notes alacritty 0.8.0 46 latest/stable snapcrafters classic ascii-patrol 1.7 152 latest/stable mr-gumix disabled ascii-patrol 1.7 159 latest/stable mr-gumix - asciinema 2.1.0 32 latest/stable asciinema classic asciinema 2.0.2 16 latest/stable asciinema disabled,classic [...]
Adding a snap name to the snap list --all command will return results only for that snap:
$ snap list --all vlc Name Version Rev Tracking Publisher Notes vlc 4.0.0-dev-4620 560 edge videolan✓ disabled vlc 3.0.4 555 edge videolan✓ -
A previously used snap that was reverted from will display disabled in the Notes column of the output.
Manually keeping track of which snap revisions available is generally unnecessary. A single revision will only ever be in use at a time, and snapd will remove old revisions automatically.
Create and restore a snapshot
A snapshot is a copy of the user, system and configuration data stored by snapd for one or more snaps on your system. This data can be found in
/var/snap/<snap-name> (see Data locations for more details).
Snapshots are generated manually with the
snap save command and automatically when a snap is removed. A snapshot can be used to backup the state of your snaps, revert snaps to a previous state and to restore a fresh snapd installation to a previously saved state.
snap save command creates a snapshot for all installed snaps, or if declared individually, specific snaps:
$ sudo snap save Set Snap Age Version Rev Size Notes 30 core 1.00s 16-2.37~pre1 6229 250B - 30 core18 886ms 18 543 123B - 30 go 483ms 1.10.7 3092 387B - 30 vlc 529ms 3.0.6 770 882kB -
restore command replaces the current user, system and configuration data with the corresponding data from the specified snapshot:
$ sudo snap restore 30 Restored snapshot #30.
By default, this command restores all the data for all the snaps in a snapshot. You can restore data for specific snaps by simply listing them after the command, and for specific users with the
Excluding a snap’s system and configuration data from snap restore is not currently possible.
See Snapshots for further details on creating, exporting, importing and validating snapshots.
Disable and enable snaps
If a snaps is temporarily undesired, it can be disabled and later enabled again. This avoids having to remove and reinstall them in the system:
$ sudo snap disable vlc vlc disabled $ sudo snap enable vlc vlc enabled
Remove a snap
To remove a snap from your system, along with its internal user, system and configuration data, use the remove command:
$ sudo snap remove vlc vlc removed
--no-wait option to return immediately to the command prompt and run the removal in the background.
By default, all of a snap’s revisions are also removed. To remove a specific revision, add the
--revision=<revision-number> argument to the remove command.
Prior to removal (except on Ubuntu Core systems), a snap’s internal user, system, and configuration data is saved as a snapshot (snapd 2.39+), and retained for 31 days.
To remove a snap without generating a snapshot, use the additional
$ sudo snap remove vlc --purge vlc removed
However, a snapshot can be used to restore the state of your snap upon reinstallation. See Snapshots for further details.
Last updated a month ago.