mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-29 21:41:00 +08:00
161 lines
5.9 KiB
Markdown
161 lines
5.9 KiB
Markdown
|
[#]: subject: "How to Install and Use Snap Packages in Ubuntu"
|
|||
|
[#]: via: "https://www.debugpoint.com/how-to-install-and-use-snap-packages-in-ubuntu/"
|
|||
|
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
|||
|
[#]: collector: "lkxed"
|
|||
|
[#]: translator: " "
|
|||
|
[#]: reviewer: " "
|
|||
|
[#]: publisher: " "
|
|||
|
[#]: url: " "
|
|||
|
|
|||
|
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][1]. 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][2] 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][3]
|
|||
|
|
|||
|
You can give the name as an argument to find a specific snap package.
|
|||
|
|
|||
|
```
|
|||
|
snap find name_of_package
|
|||
|
```
|
|||
|
|
|||
|
![snap find name][4]
|
|||
|
|
|||
|
#### 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][5]
|
|||
|
|
|||
|
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][6]
|
|||
|
|
|||
|
#### 4. List your installed snaps
|
|||
|
|
|||
|
To list down all the snap packages installed in your system, use the below command;
|
|||
|
|
|||
|
```
|
|||
|
snap list
|
|||
|
```
|
|||
|
|
|||
|
![snap list][7]
|
|||
|
|
|||
|
#### 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][8]
|
|||
|
|
|||
|
#### 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][9]
|
|||
|
|
|||
|
#### 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.
|
|||
|
```
|
|||
|
|
|||
|
![snap err][10]
|
|||
|
|
|||
|
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][11]
|
|||
|
|
|||
|
- 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][12]
|
|||
|
|
|||
|
- 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][13].
|
|||
|
|
|||
|
--------------------------------------------------------------------------------
|
|||
|
|
|||
|
via: https://www.debugpoint.com/how-to-install-and-use-snap-packages-in-ubuntu/
|
|||
|
|
|||
|
作者:[Arindam][a]
|
|||
|
选题:[lkxed][b]
|
|||
|
译者:[译者ID](https://github.com/译者ID)
|
|||
|
校对:[校对者ID](https://github.com/校对者ID)
|
|||
|
|
|||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|||
|
|
|||
|
[a]: https://www.debugpoint.com/author/admin1/
|
|||
|
[b]: https://github.com/lkxed
|
|||
|
[1]: https://snapcraft.io/
|
|||
|
[2]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/
|
|||
|
[3]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-find.png
|
|||
|
[4]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-find-name.png
|
|||
|
[5]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-install.png
|
|||
|
[6]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-refresh.png
|
|||
|
[7]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-list.png
|
|||
|
[8]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-remove.png
|
|||
|
[9]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-changes.png
|
|||
|
[10]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-err.png
|
|||
|
[11]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-changes-abort.png
|
|||
|
[12]: https://www.debugpoint.com/wp-content/uploads/2016/07/snap-abort.png
|
|||
|
[13]: https://snapcraft.io/docs
|