Snap

Using Snap Package Manager on Ubuntu

Snap is a tool used to bundle an app and its required dependencies so that it works on different Linux distributions without any modification.

Snap apps are hosted in the Snap Store. At the time of this writing, there are thousands of open-source and proprietary apps available in the snap store.

In this article, I am going to show you how to use the Snap package manager on Ubuntu. So, let’s get started!

Searching for Snap Packages

To install a Snap package, you need to know the package’s name and whether it is available in the Snap package repository or not. To find this information, you can search the Snap package repository for your desired software/app from the command-line very easily.

For example, to search for the JetBrains PyCharm IDE, search for the packages that match the pycharm keyword with the following command:

$ sudo snap find pycharm

The Snap packages that matched the pycharm keyword should be listed.

You should find the name of the Snap package, the version that is going to be installed by default, the name of the publisher, and its summary.

Knowing More About a Snap Package

Before you install a Snap package, you may want to know more about it.

To know more about, let’s say, the Snap package pycharm-community, run the following command:

$ sudo snap info pycharm-community

A lot of information about the pycharm-community Snap package should be displayed.

In the top section, you have the name, a summary, the publisher name, the Snap Store URL, the official page of the software/app it installs, the license, the description, and the ID of the Snap package.

In the bottom section, you have a list of all the available channels, or you can say versions of the software/app, you want to install. The latest/stable channel should be the default for all the Snap software/apps. If you want to install an older version of the software/app, you can specify the required channel during the installation of the Snap package.

Installing a Snap Package

To install the latest stable version of the PyCharm Community software/app, you can install the pycharm-community Snap package as follows:

$ sudo snap install pycharm-community

If you want to install a specific version of the software/app from the Snap Store, you can specify the channel to use during installation with the –channel command-line option as follows:

$ sudo snap install pycharm-community --channel latest/stable

Some Snap Store software/app will show you the following error message. This is because Snap software/apps use sandboxes for an extra layer of security. Sandboxing a Snap software/app will not let the software/app modify the filesystem outside the sandbox (its specified installation directory).

Some software/apps will need to modify the filesystem (i.e., a text editor or IDE). So, you can’t use the sandbox feature of Snap for these software/apps. To install the Snap Store software/apps that need to modify the filesystem, you must use the –classic command-line option during installation.

You can install a Snap Store software/app (i.e., pycharm-community) that does not use the sandboxing feature of Snap as follows:

$ sudo snap install pycharm-community --channel latest/stable --classic

The Snap software/app is being downloaded from the Snap Store, and it may take a while to complete.

At this point, the Snap package should be installed.

Once the PyCharm Community snap package is installed, you should be able to find it in the Application Menu of Ubuntu. You can run it just like any other apps.

Listing Installed Snap Packages

You can list all the Snap Store packages that are installed on your Ubuntu machine with the following command:

$ sudo snap list

All the Snap Store packages that are installed on your computer should be listed.

Upgrading a Snap Package

Upgrading a Snap Store package is easy.

To demonstrate the process, I have installed the webstorm (JetBrains WebStorm IDE) Snap Store package on my Ubuntu machine, as you can see in the screenshot below.

$ sudo snap list

You can upgrade the webstorm Snap Store app with the following command:

$ sudo snap refresh webstorm

You can also upgrade to downgrade a specific channel of the app.

For example, I have the 2019.3/stable channel of the webstorm Snap Store app installed on my Ubuntu machine. And, let’s say, you want to upgrade to the latest/stable channel.

$ sudo snap info webstorm

To upgrade the webstorm Snap store app to the latest/stable channel, you can run the following command:

$ sudo snap refresh webstorm --channel latest/stable

The webstorm Snap Store app is being updated to the latest/stable channel.

The webstorm app is upgraded to 2020.3.1, as you can see in the screenshot below.

Webstorm Snap app is upgraded to the latest/stable version 2020.3.1.

Disable and Enable Snap Apps

In a traditional package management system, you can only install, uninstall, or upgrade a package.

One big advantage of Snap Store apps is that you can disable an app if you no longer need it. When you disable a Snap Store app, it will still be available on your computer, but the Snap daemon won’t load the app. You can enable the app whenever you need it.

I think this is a very good solution. If you don’t need an app all the time, you can keep it disabled and enable it only when you need it. This may save a lot of memory on your computer.

Right now, the WebStorm IDE is installed on my Ubuntu machine from the Snap Store. So, I can now access it from the Application Menu of my computer.

To disable the webstorm Snap Store app, run the following command:

$ sudo snap disable webstorm

The webstorm Snap Store app should be disabled.

As you can see, the disabled option is added to the webstorm Snap Store app.

$ sudo snap list

Now, you won’t find the WebStorm IDE app on the Application Menu of your computer.

To enable the webstorm Snap Store app again, run the following command:

$ sudo snap enable webstorm

The webstorm Snap Store app should be enabled.

The disabled option is removed from the webstorm Snap Store app once it is enabled.

Once you have enabled the webstorm Snap Store app, the WebStorm IDE should be available in the Application Menu of your computer again.

Uninstalling a Snap Package

If you don’t like a Snap Store app that you have installed, you can uninstall it easily.

For example, to remove the webstorm Snap Store app, run the following command:

$ sudo snap remove webstorm

The Snap Store app webstorm should be removed.

You can then see that the Snap Store app webstorm is not on the list anymore.

$ sudo snap list

Conclusion

In this article, I have shown you how to search for Snap Store packages and find more information about a Snap Store package. I have shown you how to install, upgrade, enable/disable, and uninstall a Snap Store package. This article should help you get started with Snap package manager on Ubuntu.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.