Using Snap Packages In Ubuntu [Complete Beginners Guide]

Brief: A beginner’s guide to using Snap packages in Ubuntu 16.04. You can also download a free cheat sheet for quick reference.

One of the most talked about Ubuntu 16.04 features is Snap packaging. Canonical has introduced a new packaging system keeping convergence in mind. It’s said to be more stable and secure.

However, that secure part of the claim is debatable as a developer shows how easily its security can be circumvented using X11. Debates apart, let’s see what is Snap packaging and how to use Snap packages in Ubuntu 16.04.

Exclusive bonus: Download snap command cheatsheet for future reference. You can print it or save it for offline viewing.

What are Snap packages?

First, what is ‘packaging’? There are several ways you can install programs in Linux systems. One way is to install it from source code. In here, you manually run the scripts, build dependencies etc. Not user-friendly at all.

This is where ‘packages’ come into the picture. After developing the program, developers ship them in “software packages” so that it can be easily installed. .deb (Debian software packaging) got popular for this reason. The binaries are available in the .deb, one-to-two clicks, and the software is installed.

Now, what was the need for another packaging system for Ubuntu when it is based on Debian and .deb is heavily used in Ubuntu as well? Canonical did it for convergence (similar user experience on a variety of devices) and it is being used in Drones and other similar IoT projects.

From its official website:

A .snap package for the Ubuntu Core system contains all its dependencies. This has a couple of advantages over traditional deb or rpm based dependency handling, the most important being that a developer can always be assured that there are no regressions triggered by changes to the system underneath their app.

Suggested read
Using apt-get Commands In Linux [Complete Beginners Guide]

How to use Snap packages in Ubuntu 16.04

Enough talking about Snap packaging. Let’s see how you could use Snap packages in Ubuntu 16.04 right now.

I presume that you have experience with our popular “apt-get” commands. If not, I recommend reading my other beginner’s guide to apt-get commands in Linux.

Snap is similar to that. It can be used in the terminal and provides a basic set of commands.

1. Finding Snap packages to install

Before we see the command line way, let me tell you about the GUI way. There is an entire website (not managed by Ubuntu) that lists all the Snap packages available. This website is originally meant for listing applications available for Ubuntu Touch but since that uses Snap packaging, you can also use it to browse Snap packages for Ubuntu desktop.

Browse Snap packages at uApp Explorer

To find Snap packages in terminal, use the following command:


snap find <search_text>

The good thing about the above command is that the search query need not to be exactly the same as the package name. It finds all the matching content with that search query.

Finding Snap packages for installation in Ubuntu Linux
Search for Snap packages

2. Install Snap packages

Once you have found your desired Snap package, you can install the Snap package using the command below:

sudo snap install <package>
Install snap package in Ubuntu 16.04
Install Snap package

Do note that you need to give the exact name of the package to install it. Unfortunately, it Snap install doesn’t auto-complete the package name.

3. Keep track of Snap packages

You can also list all the Snap packages installed on your system:

snap list
List all the installed Snap packages in Ubuntu 16.04
List all the installed Snap packages

As you can see, Ubuntu core in Ubuntu 16.04 is already using Snap.

Snap also provides you a history of the changes made to your system with Snap. Use the command below:

snap changes
See the changes made with Snap in Ubuntu 16.04
See the changes made with Snap

It shows all the recent changes I did to my system with Snap.

4. Upgrade and downgrade Snap packages

If you want to upgrade a Snap package to a newer version, use the command below:

sudo snap refresh <package>
Upgrade an installed Snap package
Upgrade an installed Snap package

If the package is already the newer version, it will throw an error.

To see which Snap packages have updates ready to be installed, you can use the command below:

sudo snap refresh --list

For some reason, if you did not like a recent updated Snap package, you can revert it to the previously installed version with this command:

sudo snap revert <package>

5. Remove Snap packages

Finally, you can remove a Snap package using this command:

sudo snap remove <package>
Uninstall a Snap package
Remove Snap packages

At the time of writing this article, Snap doesn’t support auto-completion like apt and apt-get do.

If you prefer videos, here is a quick video at our YouTube channel:

Note: Commands and option may change

Snap is under continuous development. This has resulted in the change of commands and its options. There have been several changes to the commands since this article has been first published.

The option to upgrade all installed Snap packages has now gone among other such changes. So if you notice other such changes, please notify me so that I can update the article accordingly.

Worth a Snap?

At present, there are not many Snap packages available. Things are not very clear around Snap at the moment but I believe that Snap will pick up the speed, especially when Canonical is pushing for it so hard. They have released Snapcraft tool so that it will be easier for developers to make Snap packages out of their programs.

If you liked this guide to use Snap packages in Ubuntu, I recommend reading my other beginner’s guide to apt-get commands in Linux.

What do you think of Snap packaging? Do you see yourself using more Snap, over apt-get/apt in near future?

Comments

  1. What kind of beginners tutorial doesn’t tell someone how to run the installed application? Cool, I can add and remove packages but can’t use them.

  2. No, the claim that snaps are more secure, is not debatable in any way. It is more secure and you will know that this is the case once you understand the situation. It isn’t debatable.

    The X11-thing has been well known forever, since it’s designed that way. The world was a very different place in the 80s, so it wasn’t necessarily a bad decision when it was made, but it’s no longer acceptable in this day and age. No package system can fix this because fixing the issue means breaking the software you’re actively trying to use. The only real way to fix it, is to replace X11, as Mr Garrett points out and which is one of the main reasons for doing so. But even though snaps can’t fix the issue with X11, it can prevent it from being an issue, because it allows you to block access to X11 to begin with. Which other popular packaging software does that? After all, not all software requires access to your window system and knowing that the window system is vulnerable, means it makes sense to block access unless it’s required. Like snaps do.

    But ok, I’ll admit that’s a little bit far fetched and removing access to X11 won’t improve real security in most cases. At least not much. However, I think people are forgetting that debs require root access. Snaps don’t. APT and PPAs provide updates by sending a new deb to your system, meaning that every update is an opportunity to root your system. Snaps remove that opportunity.

    Nobody in their right minds would say restricting root access does not improve security, hence nobody in their right minds would say snaps are not more secure. What Mr Garrett is saying, is that snaps themselves should not be given absolute trust while you’re running X11. But this is not a revelation; we’ve known this since 1984. But don’t misrepresent this to mean snaps do not increase security. They do. They just don’t fix the window system, but nobody has pretended otherwise. It is a good reminder though and I’m sure not all users are aware of these types of issues, so I’m not criticizing Matthew Garrett in any way. I just think what he’s saying gets misunderstood by a lot of people. That’s not his fault.

  3. The history of changes features seems useful. There are so many packages (and dependencies) to install in some cases I just don’t bother with removing them when I don’t need to them.

Leave a Reply

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

[i]
[i]