How to use snap packages in Ubuntu

Published on March 10, 2021 · Updated on March 10, 2021
How to use snap packages in Ubuntu

Snap is one of the simplest way of installing apps on Ubuntu. The packages are managed by [snapcraft.io](snap score), a very powerful app manager. It was first introduced in Ubuntu 16.04 LTS and is now one of the most popular ways to install applications on Ubuntu. Snap allows for universal or cross-distribution software packaging. It claims to be more stable and secure than traditional packaging software.

Snap application packages work across all Linux distributions. It is essentialy an software package manager like apt-get but works a bit differently.

How to install Snapd on Ubuntu

Snapd is the background service that mangages your snap environment on your Ubuntu system. To use snap on our Ubuntu system we need to install snap core. The snap core is a API daemon for managing the snap packages on your system. After the installation of snapd a user can interact with the daemon by using a snap client, which is also available through the same package we are going to install.

If you are running on Ubnuntu 18.04 LTS or later, snap is already installed on your system. So you basically dont need to install additional packages and are ready to go. If you are on a different system you can install the daemon like the following:

sudo apt update && sudo apt install snapd

After you installed the snap daemon, make sure you install the “core” snap packages as well with the following command:

sudo snap install core
Using Snap

snapd is now avaialable on your system, so you can start using it.

How to searach for snaps/packages

With the snap command utility, you can search for available snap packages directly from your command line. To find a specific snap package you can search like this:

snap find <search_text> 

If you want to search for the nodejs package for example you can use:

snap find nodejs

This command will list all avaiable nodejs packages available through snap.

Installing snaps

To install a package you can simply run the command:

sudo snap install <package_name>

You can also decide which channel you want to install. A snap channel is essentially a releasing tag used by snap packages.

sudo snap install --channel=edge <package_name>
How to run snaps

The snaps are usually installed under the /usr/bin/snap directory and is being added to your $PATH variable automatically during the installation process. This allows you to call any package from the command line by just typing the install package name.

<package_name>

But you can also run it using the absolute path:

/usr/bin/snap/<package_name>
How to list installed packages.

To list all installed snap pakages on your system, use the following command:

snap list

This command displays all installed snap apps on your Ubuntu.

If you want to update a specific package manually you can type:

sudo snap refresh <package_name> 

To get a list of upgradeable packages use:

sudo snap refresh --list 
Removing snap apps or packages

If you want to remove a particular snap package you can use the following command:

sudo snap remove <package_name>

With the remove command, all application code including its run time dependencies are removed from the system. If your snap package runs as a service, the service will be shut down and removed as well.

Downloading Snaps and install them offline

It is also possible to download Snap packages and install them later without an active internet connection. To do that, you first need to download the snaps you want to install. You can do so by using the command:

snap download <package_name>

This command will download 2 files, a file with the extension .assert and a file with the extension .snap. You can copy these files to any other GNU Linux system that has snap installed and install the package with:

snap ack <package.assert>
snap install <package.snap>

You don’t even need a internet connection to install the package.

Conclusion

Even though snap is still under development and there are not as much packages available as with more traditional package managers like apt-get, is is a very good software management system. Its getting more and more popular and is being adopted fairly quickly and thats for a reason. Its easy to use, convenient and very efficient.

Load Comments