How to Use Snap Package Manager on Linux

Snap is an independent package manager, which works on all Linux distributions. In order to manage these software packages, we use snapd; a background tool which allows us to interact with snap software packages, either to install them, update, or remove them.

Snap is becoming one of the most common methods to use when installing an application in Linux. The apps are put into a sandbox and the snapd service will keep them all up-to-date automatically. In this tutorial, you will learn how to use the Snap package manager on Linux.

Installing Snap on Linux

While it is true that Snap works on all Linux distributions, this is only possible if we install Snap first. The only exception is Ubuntu, which already comes with Snap installed on versions 16.04 LTS (Xenial Xerus) or later.

To install Snap, you can execute the commands below.

For Ubuntu and Denian based Linux distributions:

$ sudo apt update
$ sudo apt install snapd

For Red Hat and Fedora based Linux distributions:

$ sudo dnf install snapd

For CentOS:

$ sudo dnf install epel-release
$ sudo dnf upgrade
$ sudo yum install snapd
$ sudo systemctl enable --now snapd.socket

For Arch Linux:

$ git clone https://aur.archlinux.org/snapd.git
$ cd snapd
$ makepkg -si
$ sudo systemctl enable --now snapd.socket

For Manjaro:

$ sudo pacman -S snapd
$ sudo systemctl enable --now snapd.socket

Listing Snap Packages

Sometimes we might want to check on what snap packages are installed in our system. To do so, execute:

$ sudo snap list

Listing all the snap packages installed on Ubuntu

Searching for a Snap Package

This command allows you to search for a Snap package. In this example we will search for any Snap package named notepad.

$ sudo snap find notepad

Searching for a snap package on Ubuntu

Installing a Snap Package

Now, taking the image above as an example, let’s install Notepad++ using the following command:

$ sudo snap install notepad-plus-plus

Installing a snap package on Ubuntu

Updating Snap Packages

Although snapd will keep packages up-to-date automatically, we can update all Snap packages manually with the refresh command.

$ sudo snap refresh

Keep in mind that this command that we just executed, will install the new updates available.

Therefore, if we want to list the packages that need to be updated without installing them to the new version, we can follow the next command:

$ snap refresh --list

Listing the snap packages that can be updated manually

As we can see in the output above, there is a new version available for firefox. We can update it using the next command:

$ sudo snap refresh firefox

Updating a snap package manually

Enabling and Disabling Snap Packages

You can disable a snap without uninstalling it:

$ sudo snap disable package_name

To enable it again:

$ sudo snap enable package_name

Removing a Snap Package

If you aren’t happy with a Snap package that you just installed, just remove it with:

$ sudo snap remove firefox

Removing a snap package from Ubuntu

Downgrade a Snap Package

If you want to downgrade an installed Snap package to the previous version, execute:

$ sudo snap revert package_name

List Services Used by a Snap Package

To see a list of services that utilize an installed Snap package, execute:

$ snap services package_name

Starting and Stopping Snap Services

To start a snap service:

$ sudo snap start service_name

To restart a snap service:

$ sudo restart service_name

To stop a snap service:

$ sudo snap stop service_name

Leave a Comment

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