A tutorial on how to find, install and maintain snap packages in Ubuntu.
Snappy (in short, Snap) packages are transactional packages developed by Canonical for Ubuntu for its line of solution offerings. Due to its transactional nature, snap packages can be used in across Linux Distributions. Snap packages are handy due to their atomic update in nature for critical industrial use cases such as IoT.
The packages can be found and installed via the command line, primarily from a web store called Snapcraft. The snap packages can also be downloaded from this store as .snap files, containing all the dependencies needed inside the .snap package.
The installed snap software is installed in their respective folders and doesn’t interfere with the rest of the system. That means if you have installed software via typical
apt-get install xyz and installed the same software by installing
xyz.snap, then both versions of the same software can co-exist on your PC without interfering with each other.
In contrast, Flatpak also has a similar concept and offers much more robust offerings, mainly for GUI-driven apps.
This article will show you how to perform basic operations with snap via the command line.
Table of Contents
How to install and manage Snap packages in Ubuntu
1. Find a Snap Package
To find a snap package, run the below command. It will give you a list of all available snap packages, their version and description.
You can give the name as an argument to find a specific snap package.
snap find name_of_package
2. Install a Snap Package from Command Line
To install a snap package, run the below command with the snap package name.
sudo snap install name-of-the-package
The command will install the package with all of its dependencies in your system. In addition, you can also see the progress of your installation.
After installation, you can launch the application directly from the application menu.
3. Updating Snap Package
You can update an installed snap package by using the below command:
sudo snap refresh name-of-the-package
4. List your installed snaps
To list down all the snap packages installed in your system, use the below command;
5. Removing (or uninstalling) a snap package
To remove a snap package from your system, run the below command:
sudo snap remove name-of-the-package
6. View Snap Activity
To view the recent changes done using snap in your system, run the below command. This will give the installed/updated activity list in those snap packages with the date and time stamps.
7. Handling Snap Errors
There are some errors you may encounter while installing/maintaining snap packages. E.g. while downloading a snap package via command
snap install, if you press
CTRL+C for abort, then you may get the below error while trying for the second time and so on. This is so bad that you can’t even install any other snap packages.
error: can't install "notes": snap "ubuntu-core" has changes in progress.
Ideally, when you do the same when installing via the apt install command, apt will take care when you run it for the second time.
To solve this error, follow these steps:
- Run the below command to find out the ID of the error installation.
- As you can see, ID=7 is the installation which I aborted. Now, run the below command with the ID.
sudo snap abort 7
- This will abort the pending change that still has a pending task. Now you can continue installing the same package or a different package.
In this article, you learned some fundamental commands for managing snap packages in the Ubuntu system via the terminal. This should get you started for now. Also, for more common tasks such as install and remove – you can visit snapcraft.io and use install methods there. Further documentation about snap is available in the official reference.