Putorius
Linux Tutorials

Using Snap Packages in Linux - A Beginners Guide to Snapd

Snaps are software packages developed by Canonical initially for Ubuntu. Now they are available for all major Linux distributions and exhibit significant benefits over typical packaging systems like APT, RPM, and Pacman. The package manager used to manage snaps is known as snappy and the service behind it is known as snapd.

Benefits of Using Snap Packages

In this article, we will explain how to install snapd on Linux OS. We will be covering the use of snap (and the snap store) to manage and run snap packages. You can use either the GUI or the command line to manage snaps. We will focus more on managing the snaps via the command line as it offers advanced functionalities.

Installing Snapd

Snapd can be easily installed from the command line. For that, you will need the root account or a standard account with sudo privileges.

Install Snapd on Ubuntu, Debian, or Linux Mint

First, you need to update the package manager:

sudo apt update

Then install Snapd:

sudo apt install snapd

Install Snapd on Fedora, CentOS, or Red Hat

sudo dnf install snapd

NOTE: You should log out and log back in to update snap's paths!

Verify Install and Show Snap Version Information

A quick way to verified Snap is installed is to pass version as an argument to the command.

kbuzdar@Linux-debian:~$ snap version
snap    2.44.3
snapd   2.43.3
series  16
debian  10
kernel  4.19.0-5-amd64

If you receive output similar to above, that indicates that snap is successfully installed.

Create Optional Sym Links for Fedora

You need to create a symlink to enable classic snap support on Fedora.

sudo ln -s /var/lib/snapd/snap /snap

To make your installed snaps show up in the Gnome Application menu add the following symlink.

sudo ln -s /usr/libexec/snapd /usr/lib/

NOTE: You should log out and back in again to once again ensure snaps paths are updated correctly.

Managing Snaps via GUI

In order to manage the snaps via GUI, you will need to install the Snap Store. Snap Store is an application that can be used to search and install new snaps or remove existing ones.

Install Snap Store

To install Snap store, open the command line Terminal, and type the following command:

$ sudo snap install snap-store

Once installed, you can launch the Snap store simply with the following command:

$ snap-store

Additionally, you can open the snap store from the Gnome applications menu. Simply hit the super key and search for Snap Store, or find it in the list of installed applications.

Installing Snaps from the Snap Store

Installing snaps via GUI is a straightforward method. Simply search a snap using the search button at the top left corner of the snap store.

You can use the search function on the top left to search for the desired snap package. Alternatively you can browse the categories.

Once you find a snap, simply click install button on the top left to install it.

Removing or Uninstalling Snaps From the Snap Store

To see and remove installed snaps, click the installed tab at the top of the windows. You will be presented with a list of installed snaps. Each one will have a convenient remove button next to it which can be used to uninstall a snap.

Launching Installed Snaps from the GUI

You can launch an installed snap just like you would any other program. Open the Gnome applications menu by hitting the super key. Then either search by typing the name or find it in the applications list.

Managing Snaps via Command Line

Search for Available Snaps

With snap, you can quickly search for available packages using the relative keywords. It can be helpful when you are uncertain about the exact name or spelling of the snap package.

$ snap find <search_keyword>

Example:

$ snap find plex
Name             Version                Publisher  Notes  Summary
plexmediaserver  1.19.2.2737-b69929dab  plexinc✓   -      Plex magically organizes your media libraries and streams them to any device
tizonia          0.18.0                 tizonia    -      Cloud music from the Linux terminal
sickgear         0.21.30                sickgear   -      SickGear automates TV
filebot          4.9.1                  filebot    -      The ultimate TV and Movie Renamer
champ            0.0.1~git              si-dz0ny   -      Plex 2nd screen player
tvhproxy         1.0                    morphis    -      A small flask app to proxy requests between Plex Media Server and Tvheadend

This command returns a list of packages that matched the search keyword.

Install Snap Package

When you find the exact name for your snap package, it can be installed with the install option.

$ sudo snap install <package_name>

Example:

$ sudo snap install riot-web

Listing Installed Snap Packages

You can list all of the installed snaps in your system using the list option.

$ snap list                                                                                                  
Name           Version    Rev   Tracking       Publisher              Notes
capturegrid4   v4.15      53    latest/stable  kuvacode               -
core           16-2.44.3  9066  latest/stable  canonical✓             core
core18         20200427   1754  latest/stable  canonical✓             base
powershell     6.2.4      88    latest/stable  microsoft-powershell✓  classic
riot-web       1.5.15     76    latest/stable  popey                  -

This listing also shows some basic information about the packages.

Show Detailed Information About a Snap Package

Each package contains important meta data like publisher, id, channels, etc. To get a detailed listing for a snap use the info option.

$ snap info <package_name>

Here is example output for the solitaire snap package:

$ snap info solitaire
name:      solitaire
summary:   usual Solitaire card game, as known as Patience or Klondike
publisher: Sylvain Becker (1bsyl)
store-url: https://snapcraft.io/solitaire
contact:   sylvain.becker@gmail.com
license:   unset
description: |
  This is the usual Solitaire card game. Also known as Patience or Klondike.
commands:
  - solitaire.1bsyl
snap-id:      0rnkesZh4jFy9oovDTvL661qVTW4iDdE
tracking:     latest/stable
refresh-date: today at 21:59 EDT
channels:
  stable:    1.0 2017-05-17 (2) 11MB -
  candidate: 1.0 2017-05-17 (2) 11MB -
  beta:      1.0 2017-05-17 (2) 11MB -
  edge:      1.0 2017-05-17 (2) 11MB -
installed:   1.0            (2) 11MB -

Launching Installed Snaps

Once installed, the snap package can be launched simply with the command line as:

$ <name_of_snap_package>

For example, PowerShell snap can be launched as:

$ powershell

Update Installed Snaps

You can update all the installed snap packages with this command:

$ sudo snap refresh --list

To update a single package only, simply replace --list with the package name.

$ sudo snap refresh <snap_package>

Example:

$ sudo snap refresh powershell
snap "powershell" has no updates available

Downgrade Snap Package

It may be necessary to downgrade a package to its previous version because of bugs or instability issues. You can use the revert option to rollback to a previous version like so:

$ sudo snap revert <snap_package>

Example:

$ sudo snap revert powershell
powershell reverted to 6.2.4

Enable or Disable Snap Package

You may want to disable the snap temporarily when not in use. It can be done with the following command:

$ sudo snap disable <snap_package>

Example:

$ sudo snap disable sublime-text
sublime-text disabled

Similarly, to re-enable it, the command would be:

$ sudo snap enable <snap_package>

Example:

$ sudo snap enable sublime-text
sublime-text enabled

Managing Services

Some snaps have services linked to them. Use the following command to view the snap services and their status.

$ snap services
Service                          		Startup  	Current    		Notes
capturegrid4.node           		enabled            inactive  		 -
plexmediaserver.plexmediaserver	enabled	   active		 - 

Here are some commands to manage snap services.

Start a snap service,:

$ sudo snap start <service_name>

To stop a running snap service:

$ sudo snap stop < service_name>

Restart a service after making any configuration changes:

$ sudo snap restart <service_name>

Remove Snap Package

In case, you want to remove the snap package, you can do so with the following command:

$ sudo snap remove <snap_package>

Example:

kbuzdar@Linux-debian:~$ sudo snap remove sublime-text 
sublime-text removed 

Install Snap Without Internet

You can install snaps on a system without an internet connection. This is where I love snaps. To install other packages on a disconnected system you have to download the package and all it's dependencies. Then when you bring it over to the disconnected system, you have to hope the dependencies don't have dependencies. This can stick you in what I call "dependency hell".

Since snaps are packaged with all their dependencies, you can easily download them and sneaker net them to a disconnected system.

Of course, you will need a connected system to download the files. You can do so with the following steps:

In a system with an internet connection, download the required snap package:

$ sudo snap download <snap_package>

Example:

$ sudo snap download powershell
Fetching snap "powershell"
Fetching assertions for "powershell"
Install the snap with:
   snap ack powershell_104.assert
   snap install powershell_104.snap

It will download the two files with .assert and .snap extensions on the system.

$ ls -l
total 65712
drwxr-xr-x 2 kbuzdar kbuzdar     4096 Apr 30 17:27 Desktop
drwxr-xr-x 2 kbuzdar kbuzdar     4096 Apr 30 17:27 Documents
drwxr-xr-x 2 kbuzdar kbuzdar     4096 Apr 30 17:27 Downloads
drwxr-xr-x 2 kbuzdar kbuzdar     4096 Apr 30 17:27 Music
drwxr-xr-x 2 kbuzdar kbuzdar     4096 May  2 18:19 Pictures
-rw-r--r-- 1 root    root        5682 May  2 18:44 powershell_104.assert
-rw------- 1 root    root    67239936 May  2 18:44 powershell_104.snap
drwxr-xr-x 2 kbuzdar kbuzdar     4096 Apr 30 17:27 Public

Place these files on the system that has no internet connection.  Then using the command line, navigate to the directory where these files have placed and run:

$ snap ack package_name.assert

Then install the snap using:

$ snap install package_name.snap

Example:

$ snap ack powershell_104.assert
$ snap install powershell_104.snap
powershell 7.0.0 from Microsoft PowerShell✓ installed

Conclusion

Through this simple, yet useful snapd tool you can easily search, install, update, and remove snaps on the Linux system. You can also manage services and easily install snaps in a system with no internet connection.

Now you should be comfortable using the snap. If you have any questions or comments we would love to hear them. Sound off below!

Resources

Exit mobile version