A Comprehensive Guide to Using Snap Packages on Ubuntu

March 4, 2021

Introduction

Snaps are contained applications in the form of packaged software. The package manager for Snap apps is Snap, created by Canonical for Linux.

Snap comes preinstalled on most of the latest Linux distributions. To check if you have Snap preinstalled on your system and to see how to install Snap, read our tutorial on how to install snap on Ubuntu.

In this tutorial, you will learn how to use Snap packages on Ubuntu.

A guide to using Snap packages on Ubuntu.

Prerequisites

  • An Ubuntu system
  • Access to the command line
  • An account with sudo or root privileges
  • Snap installed and configured

How to Use Snap Packages?

Manage Snap packages in two ways – by running snap commands in the terminal or by using the Snap Store GUI app.

The Snap Store is a snap app itself. Install it by entering the following command in the terminal:

sudo snap install snap-store
Install Snap store on Ubuntu.

After the installation finishes, open it by entering the app name snap-store.

Install Snap Apps

Install a snap app using the terminal, or use the store if you prefer a graphical environment.

  • Install via Terminal

To install a snap using the terminal you need to know the exact app name. The general syntax for installing snap packages is:

sudo snap install <package_name>

Instead of <package_name> write the name of the snap app you want to install. For example:

Install Opera on Ubuntu using snap.
  • Install Using the Snap Store

To install a snap using the Snap Store app, follow these steps:

1. Open the Snap Store by entering snap-store in the terminal.

2. Click the app you want to install.

3. Select Install and enter your password. Wait for the download to finish.

Install a snap from a Snap store app.

Snap Confinement

Snap confinement describes the level of isolation of a snap on your system. The levels are:

  • Strict. Most snaps belong in this level. They run in complete isolation and cannot access your resources without requesting it.
  • Classic. The classic confinement level gives snaps the same access to system resources as traditional packages have. Installing a classic snap requires manual approval using the --classic command line argument.
  • Devmode. Reserved for snap creators and developers. A snap with devmode confinement level runs as a strictly confined snap, but has full access to system resources, and provides a debug output. Installing a devmode snap requires the --devmode command line argument. Devmode snaps don’t appear in search results and cannot be released to the stable channel.

Note: Snap is similar to apt. The basic difference is that snaps remain confined in the .snap package on the system, while the apt package manager integrates the required app dependencies on the system. Read our article to learn more about the differences between snap and apt.

Run Snaps

Run snaps in two ways:

  • Run Snaps via Terminal

To run a snap via the terminal, enter the package name in the terminal.

For example, enter snap-store to open the Snap Store app.

Note: If you get theme parsing errors when launching some snaps, this is due to incompatibilities between the fontconfig library in the snap and the hosts fontconfig. This is a known issue, and the app opens normally anyway.

  • Run Apps from the Desktop

Another way to run a snap is to search for the app in the app menu and launch it from there.

Note that it takes some time for the app to open the first time you run it. Subsequent runs are much faster.

List Installed Snaps

See a list of installed snaps in two ways:

  • List Installed Snaps in the Terminal

To list installed snaps using the terminal, use the list command:

snap list
List installed Snaps.

This shows a list of installed snaps, including the app version, revision number, snap confinement level, publisher and app notes.

  • List Apps in the Snap Store

Launch the Snap Store and click the Installed tab. That lists all snap apps on your system.

List installed snaps in Snap store.

Search for Snaps

  • Search for an app via the Terminal

Run the snap find command to search for an application. The search term doesn’t need to match the name of the application. For example, you can search for a media player by typing “media_player”.

snap find <search_term>

The <search_term> syntax implies entering a keyword or search phrase. Separate words in a phrase using an underscore _.

snap find command.
  • Search for an App via GUI

Search for an app by entering the keyword in the search box of the Snap Store or browse the available categories.

Find snap in store.

Update Snaps

Snaps automatically update to the latest available version each day. To update snaps manually, use the terminal or the Snap Store.

  • Using the Terminal

Check for updates for a single app or see all available updates:

1. Update a single app.

sudo snap refresh <package_name>

2. Enter your password and the update process starts.

Update a snap in the terminal.

This updates the app or informs the user that the latest version is already installed.

To see which snap packages have available updates, use the command below:

sudo snap refresh --list
List packages available for update.

The output lets you know if there are any updates available for your installed snaps.

  • Update Snaps via the Snap Store

For a visual approach to updating apps, enter the Snap Store and click the Updates tab. Available updates are displayed.

Update apps via Snap store.

Downgrade Snaps

If you encounter issues after updating a snap to its latest version, or if you do not like the new update for any reason, revert to the previous one by entering the snap revert command:

sudo snap revert <package_name>
revert snap command for downgrading apps.

Important: This is only possible if you had the app’s previous version on your system. Otherwise, you get an error saying that there is no revision to revert to. This also works when you try a beta version of an app and want to revert to the stable one.

Remove Snaps

  • Remove Snap Packages via the Terminal

To remove a snap from the system, use the following command:

sudo snap remove <package_name>
Remove a snap app.

The procedure also removes all previous revisions. To remove a specific version, use the same command and add the --revision=<revision-number> argument.

Once an app is removed, a snapshot of the snap’s system, configuration and user data remains for 31 days.

To remove a snap without generating a snapshot, add the --purge argument to the remove command:

sudo snap remove <package_name> --purge
Remove a snap without generating a snapshot.
  • Remove Snap Package in the Snap Store

To remove a snap using the Snap Store:

1. Select the Installed tab.

2. Find the app you want to remove and click the Remove button.

Remove a snap using the Snap Store.

Enable and Disable Snaps

If you don’t need a snap, but you don’t want to remove it from your system entirely, disable it by entering:

sudo snap disable <package_name>
Disable a snap.

Enable a disabled snap with the following command:

sudo snap enable <package_name>
Enable a disabled snap.

List All Running Services

Snap allows you to see the services initiated by snap apps.

Use the command snap services to list all system services launched by snap packages currently installed and enabled on your system:

List all services launched by snaps.

The output shows the service name, whether it launches on system startup, if it’s currently running and any notes available.

To list the services of a single snap, state the package name in the command:

snap services <package_name>
List the services of a single Snap.

Start, Restart, and Stop Snap Services

  • Restart Snap Services

After making changes to a snap app, restart snap services for the changes to take effect.

To restart all services, enter the following command:

sudo snap restart <package_name>

This restarts all services for a specified snap.

Restart all services.

To restart a specific individual service of an app, use the same command with the service name:

sudo snap restart <service_name>
Restart individual service.
  • Stop Snap Services

To stop all snap services, use the following command:

sudo snap stop <package_name>
Stop all services.

To stop a snap’s single service, enter the following:

sudo snap stop <service_name>
Stop individual service.

Note: If you manually stop snap services the snap app may malfunction. To temporarily disable a snap, use the --disable command instead.

To prevent a snap service from starting on boot, add the --disable argument:

sudo snap stop --disable <service_name>
Disable service on startup.
  • Start Snap Services

Use the command sudo snap start <package_name> to start all snap services:

Start all services.

On the other hand, to start an individual snap service, use the following command:

sudo snap start <service_name>
Start individual service.

The start command includes an --enable option to re-enable the automatic starting of a service on system boot.

For a service to start on next boot, add the --enable argument:

sudo snap start --enable <service_name>
Enable service to start at boot.

Download and Install Snap Apps Offline

To install snap apps on a system without Internet access, first download the necessary files on a machine with Internet connection.

To download a snap package, use the following command:

snap download <package_name>
Download a snap package.

The system downloads two files to your $HOME directory – a .assert and a .snap file.

Note: It is advisable to also download and install the “core” and “gnome-3-26-1604” snaps if they are not already present on the target system. This is because some GNOME snaps require them to function properly.

1. Copy the downloaded files to the $HOME directory of the machine on which you want to install the app.

2. Install the packages using the following commands:

sudo snap ack <package_name.assert>
sudo snap install <package_name.snap>
Install downloaded snap.

Modify Snap Configurations

Snaps that provide background services allow you to see and change their configuration options.

  • List Snap Configuration

To see a snap’s configuration options, use the sudo snap get <package_name> command.

See a snap’s configuration options.

The output shows available configuration options of the specified snap. A {...} in the output indicates that there are further options below the current key level.

The output also indicates if the specified app does not have configuration options.

To explore additional options, add the key name to the previous command:

sudo snap get <package_name> <key_name>
Configure key.
  • Change Configuration Options

To change a snap’s configuration option, use the command:

sudo snap set <package_name> <key_name>=<value>

To restore a value to its default state, use the following:

sudo snap unset <package_name> <key_name>

Alternatively, to restore a value to its default stage, use the set command but add ! at the end of the key name to restore the default value:

sudo snap set <package_name> <key_name>!

Combine ! with other setting options at the same time:

sudo snap set <package_name> <key_name>! <key_name2>=<key_value>

The system checks the configuration update. If you enter a wrong value, the system detects the error and cancels the change, reverting to the previous configuration.

Note: If the update takes longer than 5 minutes, it automatically aborts and rolls back the configuration options.

Display History of Changes Made to Your System

Snap allows the user to see the history of changes it has made on the system.

Use the snap changes command to see a full list of changes in your system.

See a full list of changes in your system.

The output shows when the change took place, its status, and a summary of what happened.

Switch Channels

Snap apps are available in several channels, depending on the apps’ development status. Switch between these channels, for example, to access a beta version of the app. Switching channels is similar to switching branches in git.

There are four available channels:

  • stable: The latest stable release of an app. Should not have any bug.
  • candidate: The release candidate (RC) of an app, close to a stable version.
  • beta: Unstable version, users still encounter bugs.
  • edge: Daily/nightly builds of an app under development.

To change to a different channel, use the following command:

sudo snap refresh <package_name> --channel=<channel_name>
Change to a different channel.

After switching the channel, the specified app gets updates from that channel. To switch back to the previous one, use the refresh command and enter the channel name.

Alternatively, use the revert command.

Revert channel change.

Conclusion

You now know how to use Snaps on Ubuntu. You also know how to use the Snap Store, modify and adjust snap services and configurations to your own preference and choose the release you like.

Feel free to download and test different apps and settings. The number of apps available is constantly increasing and snap development has picked up speed in recent years, with an audience of millions in the Snap Store.

Was this article helpful?
YesNo
Bosko Marijan
Having worked as an educator and content writer, combined with his lifelong passion for all things high-tech, Bosko strives to simplify intricate concepts and make them user-friendly. That has led him to technical writing at PhoenixNAP, where he continues his mission of spreading knowledge.
Next you should read
How to Install Snap on Ubuntu
February 25, 2021

Snaps are self-contained application packages with mediated access to the system they are installed on. They...
Read more
Snap vs APT: What's the Difference?
January 21, 2021

The software in Linux is traditionally organized in repositories that contain applications and all the...
Read more
APT vs APT-GET: What's the Difference?
June 25, 2020

Since Linux introduced the apt command line tool with the Ubuntu 16.04 release, many users wondered what the...
Read more
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application software for Linux typically...
Read more
  • © 2021 Copyright phoenixNAP | Global IT Services. All Rights Reserved.