Although Ubuntu 16.04 – which was released last month – brings several changes to the table, one of the most talked about new features included in this latest Ubuntu version is Snap, which is basically a new packaging format. Fret not, the legacy deb packaging format isn’t going anywhere (at least for now); the new OS release supports both.
Just like the long-known deb format has its own commands to perform operations on .deb packages, there are commands dedicated to managing Snap packages as well. In this article we will learn how to perform basic management operations on Snap packages.
Before proceeding towards learning the practical usage, it’s important that you are theoretically clear about the new packaging system.
In layman’s terms, we can say that this new packaging system is aimed at making package installation and maintenance easier. For example, unlike the existing system, where it’s on you to resolve all version-related conflicts of dependencies for a software being installed, Snaps allow developers to put in everything their software depends on in the package itself, effectively making them self-contained and independent of the system on which they are being installed.
Here’s what Canonical (Ubuntu’s parent company) has to say about Snap:
Snap packages enable developers to bring much newer versions of apps to Ubuntu 16.04 LTS. Users can install a snap without having to worry whether it will have an impact on their other apps or their system. Similarly, developers have a much better handle on the update cycle as they can decide to bundle specific versions of a library with their app. Transactional updates make deployments of snap packages more robust and reliable.
Interested in learning more about Snap? Head to the discussion here.
Snap package management commands
Before jumping to the standard Snap commands, you first need to install the snappy command line tools on your system, if they haven’t been already, by following this command:
sudo apt install snapd
Install Snap packages
The following is the template command for installing Snap packages:
sudo snap install [packagename]
For example, here is the command I used to install the “htop” application:
sudo snap install htop
This is how it was installed:
208.00 KB / 208.00 KB [========================] 100.00 % 79.66 KB/s Name Version Rev Developer htop 2.0.1 3 maxiberta
List all installed Snaps
To display a summary of all the installed Snap packages on your system, run the “Snap” command with
Update a Snap
To update a particular snap to a more recent or latest version, use the
refresh sub-command followed by the package name. For example, if in the future I’ll have to update the “htop” tool, I’ll run the following command:
sudo snap refresh htop
Find Snap packages
find sub-command is available for this operation. It queries for available packages. Here’s an example:
You can also search for a particular Snap, such as this example:
sudo snap find webdm Name Version Summary webdm 0.18 # Snappyd
Remove a Snap
Similar to the way you install a Snap, you can easily remove a Snap package from your system – the sub-command to use in this case is
remove. In this example I removed the “htop” tool:
sudo snap remove htop
Please note that Snap’s man page talks about a
purge sub-command in the section discussing
remove. Specifically, it says that with the
remove sub-command, the snap’s data is currently not removed; use purge for that. However, in reality, there’s currently no “purge” sub-command available. Somebody even filed a bug report related to this. From what we can tell, the man page isn’t yet updated as it ends the section saying, “this behaviour will change before 16.04 is final.” Don’t get confused.
For more available options, go through the Snap man page (run
man snap on the command line).
The Snap packaging system has been developed keeping user convenience as well as developer convenience in mind. However, given that it’s been made available to mainstream Ubuntu users in the latest release, there may be some bugs or missing features.
It’s not difficult to learn Snap commands, so we’d encourage you to start using this new system and report any bugs or feature requests through proper channels. It would help the Snap system mature. And as for deb, it’s not going away in the near future for sure but will definitely be phased out over the coming years.