How to install and use Snap on Ubuntu

Snapcraft logo

Snapcraft is a next-generation package manager by Canonical. Using Snap you can install complex applications with one click, let’s take a look at how to install Snap and use it!

What is Snap? How do I install it on X distribution?

Snap (or Snapcraft) is an advanced package manager, you can read more about it in this article. Snap aims to run any application packaged as “snap” on any Linux distribution. However Snap’s not quite there yet and it works best on Ubuntu.

How to install Snapcraft

Important
I take absolutely NO responsibility of what you do with your machine; use this tutorial as a guide and remember you can possibly cause data loss if you touch things carelessly.

Installing Snapcraft is surprisingly on any recent version of Ubuntu (>=14.04):

Ubuntu >= 14.04
$ sudo apt-get install snap

Once you have installed snap you can easily check its version:

$ snap version
snap    2.34.2+18.04
snapd   2.34.2+18.04
series  16
ubuntu  18.04
kernel  4.15.0-29-generic

Basic operations

Searching for Snaps

Ubuntu

Searching for Snaps is easy, you can do it directly in the command line:

$ snap search "hello world
Name                             Version              Publisher                 Notes  Summary
hello-world                      6.3                  canonical                 -      The 'hello-world' of snaps

Or, if you prefer there’s an official store for Snaps.

Installing a Snap

Ubuntu

Once again, installing a Snap is quite easy:

$ sudo snap install hello-world
2018-12-27T18:19:45Z INFO Waiting for restart...
hello-world 6.3 from 'canonical' installe

Now you can easily use:

$ hello-world

Programs installed through Snapcraft can be found in : /snap/bin. This folder is added to $PATH by default so that you don’t have to enter the full path every time you call a command.

Removing a Snap

Ubuntu
$ sudo snap remove hello-world
hello-world removed

Updating a Snap

Snaps are automatically updated but you can check for updates using this command:

Ubuntu
$ sudo snap refresh hello-world
snap "hello-world" has no updates available

Advanced functions

Snapcraft provides some advanced features such as update rollbacks and software “deactivation” (uninstalling without uninstalling).

Enabling/Disabling a Snap

There may be times where an installed snap is unused but you want to keep it on your system. In this case you can enable/disable the Snap:

Ubuntu

To disable:

$ sudo snap disable hello-world
hello-world disable

To enable:

$ sudo snap enable hello-world
hello-world enabled

Reverting an update (rollback)

Ubuntu

To revert an upgrade:

$ sudo snap revert hello-world

Beware: a reverted Snap won’t automatically update and Snap will only try to keep three previous revisions (versions).

Managing services

There may be Snap that contain complex software such as daemons, in this case you can manage their state using Snap as well!

Listing services

Ubuntu

To revert an upgrade:

$ sudo snap services
Service       Startup  Current
lxd.activate  enabled  inactive
lxd.daemon    enabled  inactive

Of course you won’t see anything here unless you have Snap that use services.

Starting/stopping services (also on boot)

Ubuntu

To start a service:

$ sudo snap start lxd.daemon
Started.

To enable the service at boot use the –enable flag in the previous command.

To stop a service:

$ sudo snap stop lxd.daemon
Stopped

To disable the service at boot use the –disable flag in the previous command.

Inspecting logs

Ubuntu
$ sudo snap logs lxd.daemon
[Output omitted]


Image courtesy of mark | marksei

The following two tabs change content below.
The IT guy with a little boredom look in his eyes, fond of computers since forever he now works as a freelancer in the IT and shares his experiences through this blog.

Latest posts by mark (see all)

You may also like...