How to Use Snap Packages in Linux

use snap packages on Linux

Snap (snappy) is a software deployment and package management system for Ubuntu and other Linux distributions. It was introduced by Canonical since version Ubuntu 16.04 LTS.

Snap software are self-contained packages with all dependent libraries included that makes installation much simpler. As packages are containerized, applications are isolated and any changes won't affect other systems.

The packages are called 'snaps', you can discover, install, and manage package from snap store.

Unlike apt and yum package, snap packages are updated automatically.  When using snap, you always install a new version of the program.

This tutorial will show you how to use snap packages in Ubuntu Linux.

Install snap on Linux

Snap by default installed in the newer version of Ubuntu and other Linux distributions. If it doesn't come with the distribution, then needs to install manually.

To install snap on Debian and Ubuntu, run:

$ sudo apt install snapd

To install snap on CentOS and RHEL, run:

$ sudo yum install snapd

How to use snap packages

Using snap commands we can find, install, list, and control updates of packages. You can also use snap store which is GUI desktop application for searching, installing, and managing the snap packages.

snap store

On Ubuntu 20.04 LTS snap-store command from terminal launches 'Ubuntu Software' Center.

Find snap packages

To search for a specific snap package, run:

$ snap find <app-name>

For example, finding the snap package of the 'vlc' program:

find a specific snap package

Moreover, you can get detailed information for the version of an application by running:

$ snap info <app-name>

snap package info

In many cases, you want to list all snap packages in the stable channel that can be installed on your Ubuntu machine. Let's run the following command line for applications discovery:

$ snap find

find all snap packages

Install snap packages

Once you found the desired snap package, you can simply install the corresponding application by using 'snap install' command with sudo privilege:

$ sudo snap install <package-name>

For example, to install docker, run:

$ sudo snap install docker

snap install a package

After the snap packages have been installed on your Ubuntu machine, you can list all of the installed files in '/var/lib/snapd/snaps/'. Snaps files are archive squashfs files with .snap file extension.

To list installed snap files, run:

$ ls /var/lib/snapd/snaps/

List files of Installed packages

List Installed snap packages

To list all the snap packages which have been installed, run:

$ snap list

snap list command

Uninstall snap packages

When a snap package is no longer being used by the Linux user, it can be removed by running the following command:

$ sudo snap remove <package-name>

For example, in order to remove the 'docker', you can simply type:

$ sudo snap remove docker

snap remove package

Controlling Snap Updates

Snap packages are always updated automatically. By default, the 'snapd' checks for updates four times per day. The update check is known as a 'refresh'.

You can update the snap packages manually. For example, to update all installed snap applications, run:

$ sudo snap refresh

snap refresh

If you want to update a specific snap package, let's run the 'snap refresh' command along with the package name. For example:

$ sudo snap refresh vlc

In order to see the schedule of 'refresh', run:

$ snap refresh --time

snap refresh time

You can control the snap updates by specifying 4 'refresh' options:

refresh.timer - define when and how frequently the snap packages are refreshed

refresh.hold - postpone the snap packages refresh until the defined time

refresh.metered - pause the snap packages refresh when network connection is metered

refresh.retain - set the maximum number of a snap package refresh revisions

Conclusion

In this tutorial, we learned how to manage snap packages on Ubuntu. Snap is a really powerful software packaging management tool for any Ubuntu user.

Thanks for reading and please leave your suggestion in the below comment section.

Bobbin Zachariah 2:20 am

Comments

Your email address will not be published. Required fields are marked *

1 Comment

  1. Thanks for the info on SNAP.
    Now I'll know how to prevent this snappy rubbish from infecting my stable Debian distro.
    I'm surprised Ubuntu don't just put it on the Google store to enhance the lock down experience?