How to Install Snap on Linux

Working with Linux, you will likely have heard of Snap in relation to installing software on a Linux system.

Snap is a software packaging and deployment system for Linux operating systems. Software packages, which are called snaps, and the program for using them, which is called snapd, work on many Linux distributions and provide a way for software developers to package and distribute their applications. Snaps are self contained applications, which run in a sandbox, with controlled access to the host operating system.

Snap provides a solution to the problem of having to develop applications to run on different Linux distributions, which require different packages etc. Snap applications run in a container with restricted access to the host system. Users can grant an application mediated access to extra functionalities of the host via Interfaces, such as recording audio and capturing video.

Developers can publish their snap-packaged programmes on the Snap Store. All programmes submitted to the Snap Store are automatically tested, including a virus scan. Although the Snap sandbox mitigates the effect of a malicious software, Canonical advises users to only install Snaps from publishers they trust.

When first released, Snap supported just the all-Snap Ubuntu Core edition, but it was adapted to a broad range of Linux distributions in June 2016. Snap needs Systemd, which is present in the majority, but not all, Linux distributions. Snap is currently supported by a variety of Linux distributions out of the box, including Ubuntu (and its derivatives, such as Kubuntu and Xubuntu), Manjaro, and others. Many other distributions, including CentOS, Debian, Elementary OS, Fedora, Kali Linux, Linux Mint, Raspbian, Red Hat Enterprise Linux, and openSUSE, support Snap.

Let’s take a look at some examples of how to install Snap on Linux.

How to Install Snap on Debian and Ubuntu based Linux distributions

To install Snap on a Debian or Ubuntu based Linux distribution, the following command can be used:

sudo apt install snapd

How to Install Snap on Red Hat and Fedora based Linux distributions

To install Snap on a Red Hat or Fedora based Linux distribution, the following command can be used:

sudo dnf install snapd

How to List Packages Installed with Snap

You can list Snap packages on your system with the snap list command:

sudo snap list
Name              Version      Rev    Tracking         Publisher   Notes
amazon-ssm-agent  3.1.1188.0   5656   latest/stable/…  aws✓        classic
core              16-2.56.2    13425  latest/stable    canonical✓  core
core18            20220706     2538   latest/stable    canonical✓  base
core20            20220527     1518   latest/stable    canonical✓  base
lxd               5.3-91e042b  23270  latest/stable/…  canonical✓  -

Find and Install a Snap

The snap find command can be used to search the snap store for snaps. For example:

snap find docker
Name                      Version              Publisher              Notes    Summary
docker                    20.10.14             canonical✓             -        Docker container runtime

Here we have found a snap for the Docker Container Runtime. The output displays the name of the snap, the version, the publisher and any notes or summary. The publisher for this one is Canonical.

We can now install it using the snap install command:

sudo snap install docker
docker 20.10.14 from Canonical✓ installed

Once complete, Docker should be installed. Now if we run the snap list command again we can see that the docker snap is listed:

sudo snap list
Name              Version      Rev    Tracking         Publisher   Notes
amazon-ssm-agent  3.1.1188.0   5656   latest/stable/…  aws✓        classic
core              16-2.56.2    13425  latest/stable    canonical✓  core
core18            20220706     2538   latest/stable    canonical✓  base
core20            20220706     1581   latest/stable    canonical✓  base
docker            20.10.14     1779   latest/stable    canonical✓  -
lxd               5.4-82d05d6  23339  latest/stable/…  canonical✓  -

More Snap Commands

You can update a snap to the latest version by using the snap refresh command:

sudo snap refresh docker
snap "docker" has no updates available

We have no updates for docker as we have just installed the latest available snap.

Finally, you can remove / uninstall a snap that is already installed by using the snap remove command.

sudo snap remove docker
docker removed

Summary

In this tutorial you have learned how to install snap on Linux. There were examples of how to install snap on Ubuntu or Debian based Linux systems, and how to install snap on Red Hat or Fedora based systems.

We then went on to running through some examples of how to install docker using snap, how to list already installed snaps and how to find snaps on the snap store.

Finally we looked at how to update a snap and how to remove or uninstall a snap from a Linux system.

Related posts

Mastering the Linux ifconfig Command

Docker Exec Command With Practical Examples

Debugging with Git Bisect

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More