Snap packages have been around since the release of Ubuntu 16.04. Just like the long-known deb format, it has its own commands for performing operations on .deb packages There are also dedicated commands for managing Snap packages. In this article, we will learn how to perform basic management operations on Snap packages in Ubuntu.
Why Snap?
Before embarking on learning the practical usage, it is important to be theoretically clear about the Snap packaging system.
The goal of this packaging system is to make installation and maintenance of packages easier and more secure. For example, unlike the current system, where you resolve all version-related dependency conflicts for an installed program, Snaps allows developers to put everything their software depends on into the package itself, making it efficient, self-contained, and independent of the system on which it is installed.
With Snapshots, software updates are also done automatically in the background, making it more convenient for the user.
Snap package management commands
Before moving on to the standard Snap commands, you first need to install the Snap command line tools on your system, if you haven't already, by following this command:
sudo apt install snapd
Install Snap packages
Here is the command to install Snap packages:
sudo snap install [packagename]
For example, this is the command I used to install the “htop” application:
sudo snap install htop
List all installed shots
To view a summary of all Snap packages installed on your system, run the command “Snap” Using the list subcommand:
snap list
Snap update
To update a particular snapshot to a newer or more recent version, use the Refresh subcommand followed by the package name. For example, if I need to update a tool in the future, “htop” So I will run the following command:
sudo snap refresh htop
Find Snap Packs
A search subcommand is available for this operation. It queries available packages. Here's an example:
snap find
You can also search for a specific Snap, like this example:
sudo snap find htop
Remove Snap
Similar to the Snap installation method, 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 tool. “htop”:
sudo snap remove htop
Disable Snap
It's also possible "Disable" The hijacker package will be installed on your computer. This will not remove the program files on your system, but it will make them inaccessible to the rest of the system. This can be useful if you want to remove a package from your PATH but still intend to use it later.
To disable the htop snap package, run the following command:
sudo snap disable htop
You can bring a snap package back from hibernation using enable:
sudo snap enable htop
Good to know: While Canonical developed Snap packages for Ubuntu, they are also available for other Linux distributions, such as Arch Linux. Find out how you can Installing Aur packages in Arch.
Snap package patch
Besides being a capable package manager, snap also provides powerful debugging commands and flags. You can use them to diagnose problems with your packages or explore in-development versions of your favorite software.
To do the latter, you can append the –edge or –beta flags to the end of the installation command:
sudo snap install --beta htop
Update existing Snap settings
The update command can also change the properties of snapshots you already have installed on your system. This is useful if you want to switch a development package to a regular stable package:
sudo snap refresh --stable htop
It also supports a number of additional flags that allow you to change the program's security policy. For example, you can use the –jailmode flag to strictly isolate a package from the rest of your system:
sudo snap refresh --jailmode htop
Tip: Security doesn't stop at isolating individual packages in your system. Learn how to protect your data online by Install privacy-focused extensions in Chrome.
Restore Snap Packages
Similar to transactional package managers, snap supports the ability to roll back updates on a per-package basis. This makes it extremely easy to roll back and prevent any misbehaving package from breaking your system.
To restore a single snap package, run the following command:
sudo snap revert htop
Just like the update subcommand, you can also use the same flags in return to close a misbehaving application:
sudo snap revert --jailmode htop
Frequently Asked Questions
Q1: Will snap replace packages I installed through apt?
The answer: No. Snap will not change any program or file currently on your system. However, one of the problems with Snap is that Ubuntu It will always download the snap package first, before any other appropriate software. This can be a problem if you configure an appropriate software before installing its snap version.
Q2: Can I remove access to the snap package file without disabling it?
The answer: Yes. You can do this by disconnecting the file access plug from your snap package. First, run: sudo snap interfaces snap-package. Next, find the plug you want to disable and run: sudo snap disconnect snap-package:plug.
Q3: Is it possible to know the configuration options for snap package?
The answer: Yes. You can check all the available configuration options for the snap package using the get subcommand. For example, you can run sudo snap get htop to get the configuration options for htop.