1. Overview
In this tutorial, we’ll learn how to use the Snap package manager, install snap packages (also called snaps), list and manage the installed snaps, and remove or disable the installed snaps on a Linux system.
A package manager is a set of software tools that automate installing, upgrading, configuring, and removing programs on a computer. Snap is a package manager developed by Canonical for operating systems that use the Linux kernel.
Snaps are programs that are packaged with all their dependencies to run on all major Linux distros. Moreover, snaps run confined within a restrictive security sandbox. Therefore, they are secure. In addition, snaps get updated automatically. So we don’t need to keep checking for updates manually.
2. Main Components of the Snap Ecosystem
There are five main components in the Snap ecosystem:
- Snapd: The snap daemon; it’s the background service that manages and maintains the snaps on a Linux system
- Snap: The command-line interface tool used to install and manage snaps on a Linux system
- Channels: A channel determines which release of a snap is installed and checked for updates
- Snap Store: It’s where developers publish their snap packages and Linux users install them
- Snapcraft: The framework tool for building snaps
Now that we have enough information about the Snap ecosystem, let’s install it.
3. Installing Snapd
We need to start with installing snapd, which is the background service that manages the snaps on a Linux system.
3.1. On Debian/Ubuntu
To install snapd on Debian/Ubuntu, we can run these commands:
$ sudo apt update
$ sudo apt install snapd
After the installation is finished, we should check the installed version:
$ snap version
snap 2.55.5
snapd 2.55.5
series 16
elementary 6.1
kernel 5.13.0-44-generic
We have successfully installed snapd.
3.2. On Fedora
We can run this command:
# dnf install snapd
After that, we’ll have successfully installed snapd on Fedora.
3.3. On Centos and Other Red Hat-Based Distros
We should run these commands:
# yum install epel-release
# yum install snapd
After that, we’ll have successfully installed snapd on the system.
3.4. On Manjaro
We should enter this command:
# pacman -S snapd
After that, we’ll have successfully installed snapd on Manjaro.
4. Enabling the Systemd Unit
After installing snapd, we should run this command to enable the systemd unit that is responsible for managing the main Snap communication socket:
$ sudo systemctl enable --now snapd.socket
After running the above command, the Snap ecosystem will be ready to interact.
5. Finding Snaps
We can use the snap command to interact with the Snap ecosystem.
snap find helps us look for packages before installing them. For example, if we want to install a media player, we can look for its category:
$ snap find "media players"
Name Version Publisher Notes Summary
vlc 3.0.16 videolan✓ - The ultimate media player
foobar2000 1.6.11 mmtrt - foobar2000 is an advanced freeware audio player.
tizonia 0.22.0 tizonia - Cloud music from the Linux terminal
audio-recorder 3.0.5+rev1432+pkg-7b07 brlin - A free audio-recorder for Linux (EXTREMELY BUGGY)
mpv 0.26.0 casept - WARNING: THIS SNAP IS UNMAINTAINED. CONTACT ME IF YOU WISH TO MAINTAIN IT.
ktube-media-downloader 4 keshavnrj - Download / Play Media from various websites
Snap has expanded the media players category for us.
6. Getting More Information About a Snap
Let’s get more information about the VLC snap:
$ snap info vlc
name: vlc
summary: The ultimate media player
publisher: VideoLAN✓
store-url: https://snapcraft.io/vlc
contact: https://www.videolan.org/support/
license: unset
description: |
VLC is the VideoLAN project's media player.
Completely open source and privacy-friendly, it plays every multimedia file and streams.
...
snap info gives us more information about a snap.
7. Installing Snaps
Now that we have found the package we wanted to install, we can install it:
$ sudo snap install vlc
This will install the latest VLC media player from the stable channel. In addition, if we wanted to install from a different channel, we can specify it with a flag.
There are four risk levels we can select from:
- Stable: For the vast majority of users running in production environments
- Candidate: For users who need to test updates before stable deployment, or those verifying whether a specific issue has been resolved
- Beta: For users wanting to test the latest features, typically outside of a production environment
- Edge: For users wanting to track development closely
For example, let’s select the beta risk level:
$ sudo snap install --channel=beta vlc
vlc (beta) 3.0.17.3-203-gaefbee5bdb from VideoLAN✓ installed
We have successfully installed the latest version of VLC from the beta channel.
8. Listing Installed Snaps
To list a summary of all the snaps that are installed on the system, we can run snap list:
$ snap list
Name Version Rev Tracking Publisher Notes
core18 20220428 2409 latest/stable canonical✓ base
ffmpeg 4.3.1 1286 latest/stable snapcrafters -
snapd 2.55.5 15904 latest/stable canonical✓ snapd
vlc 3.0.17.3-203-gaefbee5bdb 3007 latest/beta videolan✓ -
The command has displayed a summary of all installed snaps on the screen.
In addition, we can list the current revision of a snap that is installed on the system:
$ snap list vlc
Name Version Rev Tracking Publisher Notes
vlc 3.0.17.3-203-gaefbee5bdb 3007 latest/beta videolan✓ -
Moreover, we can list all revisions of an installed snap by adding –all:
$ snap list --all vlc
Name Version Rev Tracking Publisher Notes
vlc 3.0.17.3-203-gaefbee5bdb 3007 latest/beta videolan✓ -
We only had one revision available for VLC.
9. Updating Snaps
Snapd, by default, checks for updates four times a day and installs the updates if they are available. Each update check is called a refresh. The refresh command checks the channel that is being tracked by the installed snap and installs a newer version if it’s available:
$ sudo snap refresh vlc
snap "vlc" has no updates available
There were no updates available for VLC. We can also run the refresh command for all installed snaps:
$ sudo snap refresh
All snaps up to date.
There were no updates available.
10. Reverting Snaps
After updating a snap, if for whatever reason we were not happy with the new version, we can always revert to the previously installed version:
$ sudo snap revert vlc
Note that the snap’s data will also be reverted to its previous state.
11. Enabling/Disabling and Removing Snaps
If we didn’t want to use an installed snap anymore, but we still wanted to keep the snap and its data for later, we can just disable it. Later, if we want to use it again, we can re-enable it:
$ sudo snap disable vlc
vlc disabled
$ sudo snap enable vlc
vlc enabled
To remove a snap from the system, we can run snap remove:
$ sudo snap remove vlc
vlc removed
Alternatively, we can remove a specific revision of an installed snap by adding –revision. Note that we need to have disabled the selected revision beforehand:
$ sudo snap remove --revision=2344 vlc
vlc (revision 2344) removed
We have successfully removed a specific revision of VLC.
12. Conclusion
In this article, we learned about the Snap ecosystem and its main components.
The Snap ecosystem provides a convenient environment for installing and managing packages on a Linux machine. In addition, we learned how to install the Snap ecosystem on a Linux machine, look for snap packages, and get more information about them before installing them. Moreover, we learned how to install snaps and manage the installed snaps on a Linux machine.