Brief: A beginner’s guide to using Snap packages in Ubuntu 16.04. You can also download a free cheat sheet for quick reference.
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.
What are Snap packages?
First, what is ‘packaging’? There are several ways you can install beprograms 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:
.snappackage for the Ubuntu Core system contains all its dependencies. This has a couple of advantages over traditional
rpmbased 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.
How to use Snap packages in Ubuntu and other Linux
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.
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.
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>
Do note that you need to give the exact name of the package to install it. Unfortunately, Snap install doesn’t auto-complete the package name at present. I do hope that they add this feature later.
3. Keep track of Snap packages
You can also list all the Snap packages installed on your system:
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:
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>
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>
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?