Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Tuesday, January 29, 2019 at 23:21


This is an introduction and tutorial to use Canonical Snap for beginners on Ubuntu and other GNU/Linux distros. With Snap, now you can install latest software on your computer, server, and device safely in one common way without worrying about dependencies and broken system. Snaps also run on LiveCD sessions! Today, you can install over 4000 applications in Snap way including the popular GIMP, Telegram, VLC, and Nextcloud. You will find here what's Snap and what's the benefits of it for you, list of popular software already available for you in Snap way, and list of command lines with examples and explanations in using it. Enjoy your new journey!
Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.


Snap, what's so special about Snap?


For you who already accustomed to Ubuntu's way to install programs: Snap is like a single universal repository of software for all users of all GNU/Linux distros for computer, server, and device. This way, software developers just need to publish software in one repository, and users use one way to get it. Before Snap, it is really not like that, different distros like Ubuntu, Fedora, openSUSE, Arch, Solus all have different ways to install same software. Thanks to Snap, both installing software and publishing it now universal in one way only for all different distros. That's so special thing about Snap.

Understanding the name Snap


When we talk about snap, I mean it is Canonical Snap, in a whole, a technology to universally install software in one way for all GNU/Linux users. This technology is given to us in several components:
  1. Canonical Snap, the whole thing including all terms below,
  2. Snapcraft.io, the repository (central place where you download programs from), 
  3. Snap package, Snaps, the program available to you (you will download) in Canonical Snap way,
  4. snapd, is the actual tool to download in every user computer, 
  5. snap (with small s), the actual command to download Snap package,
  6. .snap, the file extension of Snap package.

So, to understand more, you go to https://snapcraft.io/store and see there are so many applications like GIMP and VLC available for you to install on your computer running GNU/Linux. How to understand? You see, talking about Canonical Snap, then Snapcraft is your repository, those GIMP and VLC are example of Snap packages, to install them you make sure snapd has been installed in your computer then you run command line $ snap install gimp vlc to install both two, and the actual programs you download are in .snap files. The amazing thing is this way is the same either you use Ubuntu or other distro. Simple, no?

What software are available?


Yes, is your favorite software available in Snap? See Canonical's statistics instead. But in order you want to know some you already know:

Using Snap


You can search, identify, install, remove, list installed, backup, and upgrade (and also downgrade) software without administrator right in your computer using Snap. How to do? See command lines below by example of Inkscape vector graphic editing application.

All commands below can work without sudo.

1) Search:
$ snap search inkscape

2) Identify:
Show versions and description information about a Snap.
$ snap info inkscape

3) Install:
$ snap install inkscape

4) Run:
$ snap run inkscape

5) Remove:
$ snap remove inkscape

6) List:
Show all installed Snaps.
$ snap list

7) Backup:
A new thing for us APT users: we can backup installed application as one single file and keep it and reuse it on any computer anywhere any time. Installing a Snap from backup does not need any internet access.
  • Copy the .snap file of Inkscape from /var/lib/snapd/snaps/ to other place safe
  • Put the .snap file to other computer with snapd already installed
  • Run command below on that other computer:
$ snap install --dangerous [filename].snap

8) Upgrade all:
Upgrade all installed Snaps to their latest versions:
$ snap refresh

9) Upgrade single:
Upgrade only one installed Snap you choose.
$ snap refresh inkscape

10) Downgrade:
Also a new thing for us APT users: we can downgrade an installed software to previous version easily and safely without worrying about dependencies and without the risk of broken operating system.
$ snap revert inkscape

Understanding The Outputs


What you need to learn in first time is the output of snap info, snap list, and snap install. We use Inkscape snap as example here. Once you know them, you can learn the other ones quicker and simpler.

1) snap info

Identifying a snap package:
$ snap info inkscape

The output:


Details about the software is in the several first lines:
name:      inkscape
summary:   Vector Graphics Editor
publisher: inkscape
contact:   https://inkscape.org/en/community/mailing-lists/#inkscape-user
license:   unknown

Multiple versions of the software is in the last lines:
channels:                    
  stable:    0.92.4   (4693) 182MB -
  candidate: 0.92.4   (4693) 182MB -
  beta:      ↑                     
  edge:      1.0alpha (4815) 161MB -

From that information we know that this snap package name is inkscape, a vector editor (similar thing to Adobe Illustrator), and there are two different versions available right now (0.92.4 and 1.0alpha), and the download size are respectively 180MB and 160MB.

2) snap list

The command:
$ snap list

The output:


From that output, we know that there are some Snap applications installed, among them are inkscape and telegram-desktop, both versions are 0.92.4 and 1.5.8 respectively.

3) snap install

The command:
$ snap install inkscape

The output:

That is how a program being installed by snap command line. Compare it to APT you get the bigger picture: snap is far more simpler. From that output we know snap is installing inkscape version 0.92.4 ("stable"), and when processing it runs a white highlight line animation mimicking progress bar following the percentage (45% means about half a way).

How if you don't know the package name?


Easy, just go to your repository, https://snapcraft.io/store. Find any program there and find the command line on the page. Click the green Install button so the information showing. You can see every Snap package there is accompanied with more information including the command. See for example ONLYOFFICE and Nextcloud here.

 (ONLYOFFICE Snap, see the command on the bottom)


(NextCloud Snap, see command line on the bottom)


Advantages of snap over normal ways


On GNU/Linux world, we know several ways of software installation.
  1. Compile software from source.
  2. Normal way, Download precompiled software from official repo of respective distro. This is the way of apt, dnf, zypper, and pacman.
  3. Flatpak, you use the flatpak command on your computer to download software from Flathub repo.
  4. Snap, you use the snap command on your computer to download software from Snapcraft repo.
  5. AppImage, you download software in .appimage format right from each developer.
The main advantage over the normal way (APT) is you can get latest version of any software quicker and easier. You do not need to add third-parties PPAs anymore. Today, 29 January 2019, the repo of 18.04 LTS does not have yet Inkscape version 0.92.4, but Snap does. Even more latest, Snap has the 1.0alpha version right now. Thanks to that, I finished my Inkscape review quickly few days ago.

The other advantage over the APT ways is obviously you can easily backup the installed software as it is only one single file. You can install that backup software on Fedora, openSUSE, Solus, and other distros without worrying about dependencies and compatibility. You can see my example: I ran many many LiveCD sessions to write that Inkscape review and I just need to reinstall Inkscape from .snap I already downloaded once and I made a backup (no re-downloading anymore).

Currently (I tested this on Ubuntu 18.04 LTS), Snap can run you software on LiveCD session. And I'm happy with that. That is the reason I can write this article quicker and easier as I can repeat processes over and over again without changing my computer. When I tried to install same software with Flatpak on LiveCD, either every attempt failed, or the download size is tremendously too big for a live session.

This article talks about Ubuntu, how about other distros?


Every other distro can have Canonical Snap simply by installing snapd using your respective normal package managers. Follow instruction below and you will be ready to practice the exercises above.

Debian:
$ sudo apt-get install snapd 

Fedora:
$ sudo dnf install snapd

openSUSE:
$ sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.0 snappy #for Leap 15$ sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_42.3 snappy #for Leap 42.3$ sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Tumbleweed snappy #for Tumbleweed
$ sudo zypper --gpg-auto-import-keys refresh
$ sudo zypper dup --from snappy
$ sudo zypper install snapd

Arch:
$ git clone https://aur.archlinux.org/snapd.git
$ cd snapd
$ makepkg -si #this may take some time
$ sudo systemctl enable --now snapd.socket

Solus:
$ sudo eopkg install snapd

Closing Words


That's all. I hope you can use Snap for your life now. Try as many Snaps as possible. Try them on a live sessions. Find more friends using Snaps on the Snap Forum. And share the .snap with your friends!

References




This article is licensed under CC BY-SA 3.0.