TranslateProject/sources/tech/20221103.4 ⭐️ How to Install and Use Snap Packages in Ubuntu.md

5.9 KiB
Raw Blame History

How to Install and Use Snap Packages in Ubuntu

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 doesnt 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 installingxyz.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.

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.

snap find

snap find

You can give the name as an argument to find a specific snap package.

snap find name_of_package

snap find name

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

snap install

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

snap refresh

4. List your installed snaps

To list down all the snap packages installed in your system, use the below command;

snap list

snap list

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

snap remove

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.

snap changes

snap changes

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 cant even install any other snap packages.

error: can't install "notes": snap "ubuntu-core" has changes in progress.

snap err

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.
snap changes

snap changes abort

  • As you can see, ID=7 is the installation which I aborted. Now, run the below command with the ID.
sudo snap abort 7

snap abort

  • This will abort the pending change that still has a pending task. Now you can continue installing the same package or a different package.

Closing Notes

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.


via: https://www.debugpoint.com/how-to-install-and-use-snap-packages-in-ubuntu/

作者:Arindam 选题:lkxed 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出