A Beginners Guide to Snaps in Linux – Part 1

In the past few years, the Linux community has been blessed with some remarkable advancements in the area of package management on Linux systems, especially when it comes to universal or cross-distribution software packaging and distribution. One of such advancements is the Snap package format developed by Canonical, the makers of the popular Ubuntu Linux.

What are Snap Packages?

Snaps are cross-distribution, dependency-free, and easy to install applications packaged with all their dependencies to run on all major Linux distributions. From a single build, a snap (application) will run on all supported Linux distributions on desktop, in the cloud, and IoT. Supported distributions include Ubuntu, Debian, Fedora, Arch Linux, Manjaro, and CentOS/RHEL.

Snaps are secure – they are confined and sandboxed so that they do not compromise the entire system. They run under different confinement levels (which is the degree of isolation from the base system and each other). More notably, every snap has an interface carefully selected by the snap’s creator, based on the snap’s requirements, to provide access to specific system resources outside of their confinement such as network access, desktop access, and more.

Another important concept in the snap ecosystem is Channels. A channel determines which release of a snap is installed and tracked for updates and it consists of and is subdivided by, tracks, risk-levels, and branches.

The main components of the snap package management system are:

  • snapd – the background service that manages and maintains your snaps on a Linux system.
  • snap – both the application package format and the command-line interface tool used to install and remove snaps and do many other things in the snap ecosystem.
  • snapcraft – the framework and powerful command-line tool for building snaps.
  • snap store – a place where developers can share their snaps and Linux users search and install them.

Besides, snaps also update automatically. You can configure when and how updates occur. By default, the snapd daemon checks for updates up to four times a day: each update check is called a refresh. You can also manually initiate a refresh.

How to Install Snapd in Linux

As described above, the snapd daemon is the background service that manages and maintains your snap environment on a Linux system, by implementing the confinement policies and controlling the interfaces that allow snaps to access specific system resources. It also provides the snap command and serves many other purposes.

To install the snapd package on your system, run the appropriate command for your Linux distribution.

------------ [On Debian and Ubuntu] ------------ 
$ sudo apt update 
$ sudo apt install snapd

------------ [On Fedora Linux] ------------
# dnf install snapd			

------------ [On CentOS and RHEL] ------------
# yum install epel-release 
# yum install snapd		

------------ [On openSUSE - replace openSUSE_Leap_15.0 with the version] ------------
$ sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.0 snappy
$ sudo zypper --gpg-auto-import-keys refresh
$ sudo zypper dup --from snappy
$ sudo zypper install snapd

------------ [On Manjaro Linux] ------------
# pacman -S snapd

------------ [On Arch Linux] ------------
# git clone https://aur.archlinux.org/snapd.git
# cd snapd
# makepkg -si

After installing snapd on your system, enable the systemd unit that manages the main snap communication socket, using the systemctl commands as follows.

On Ubuntu and its derivatives, this should be triggered automatically by the package installer.

$ sudo systemctl enable --now snapd.socket

Note that you can’t run the snap command if the snapd.socket is not running. Run the following commands to check if it is active and is enabled to automatically start at system boot.

$ sudo systemctl is-active snapd.socket
$ sudo systemctl status snapd.socket
$ sudo systemctl is-enabled snapd.socket
Check Snapd Service Status
Check Snapd Service Status

Next, enable classic snap support by creating a symbolic link between /var/lib/snapd/snap and /snap as follows.

$ sudo ln -s /var/lib/snapd/snap /snap

To check the version of snapd and snap command-line tool installed on your system, run the following command.

$ snap version 
Check Snapd and Snap Version
Check Snapd and Snap Version

How to Install Snaps in Linux

The snap command allows you to install, configure, refresh and remove snaps, and interact with the larger snap ecosystem.

Before installing a snap, you can check if it exists in the snap store. For example, if the application belongs in the category of “chat servers” or “media players“, you can run these commands to search for it, which will query the store for available packages in the stable channel.

$ snap find "chat servers"
$ snap find "media players"
Find Applications in Snap Store
Find Applications in Snap Store

To show detailed information about a snap, for example, rocketchat-server, you can specify its name or path. Note that names are looked for both in the snap store and in the installed snaps.

$ snap info rocketchat-server
Get Info About Application in Snap
Get Info About Application in Snap

To install a snap on your system, for example, rocketchat-server, run the following command. If no options are provided, a snap is installed tracking the “stable” channel, with strict security confinement.

$ sudo snap install rocketchat-server
Install Application from Snap Store
Install Application from Snap Store

You can opt to install from a different channel: edge, beta, or candidate, for one reason or the other, using the --edge, --beta, or --candidate options respectively. Or use the --channel option and specify the channel you wish to install from.

$ sudo snap install --edge rocketchat-server        
$ sudo snap install --beta rocketchat-server
$ sudo snap install --candidate rocketchat-server

Manage Snaps in Linux

In this section, we will learn how to manage snaps in Linux system.

Viewing Installed Snaps

To display a summary of snaps installed on your system, use the following command.

$ snap list
List Installed Snaps
List Installed Snaps

To list the current revision of a snap being used, specify its name. You can also list all its available revisions by adding the --all option.

$ snap list mailspring
OR
$ snap list --all mailspring
List All Installation Versions of Snap
List All Installation Versions of Snap

Updating and Reverting Snaps

You can update a specified snap, or all snaps in the system if none are specified as follows. The refresh command checks the channel being tracked by the snap and it downloads and installs a newer version of the snap if it is available.

$ sudo snap refresh mailspring
OR
$ sudo snap refresh		#update all snaps on the local system
Refresh a Snap
Refresh a Snap

After updating an app to a new version, you can revert to a previously used version using the revert command. Note that the data associated with the software will also be reverted.

$ sudo snap revert mailspring
Revert a Snap to Older Version
Revert a Snap to Older Version

Now when you check all revisions of mailspring, the latest revision is disabled, a previously used revision is now active.

$ snap list --all mailspring
Check Revision of Snap
Check Revision of Snap

Disabling/Enabling and Removing Snaps

You can disable a snap if you do not want to use it. When disabled, a snap’s binaries and services will no longer be available, however, all the data will still be there.

$ sudo snap disable mailspring

If you need to use the snap again, you can enable it back.

$ sudo snap enable mailspring

To completely remove a snap from your system, use the remove command. By default, all of a snap’s revisions are removed.

$ sudo snap remove mailspring

To remove a specific revision, use the --revision option as follows.

$ sudo snap remove  --revision=482 mailspring

It is key to note that when you remove a snap, its data (such as internal user, system, and configuration data) is saved by snapd (version 2.39 and higher) as a snapshot, and stored on the system for 31 days. In case you reinstall the snap within the 31 days, you can restore the data.

Conclusion

Snaps are becoming more popular within the Linux community as they provide an easy way to install software on any Linux distribution. In this guide, we have shown how to install and work with snaps in Linux. We covered how to install snapd, install snaps, view installed snaps, update and revert snaps, and disable/enable and remove snaps.

You can ask questions or reach us via the feedback form below. In the next part of this guide, we will cover managing snaps (commands, aliases, services, and snapshots) in Linux.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

11 Comments

Leave a Reply
  1. In many filtering proxy rule bases, snap is considered as a downloader, like apt, dnf and yum. How would you change the user-agent so to pretend it’s Chrome or Safari instead of exposing itself as snap?

    Reply
  2. Yeah, probably the most confusing thing to a new Linux user is how the heck do you install apps and why is this difference between distros? Got to be confusing for someone coming from Windows who installed most things from a download or possibly the Microsoft App store.

    Would be nice instead of re-inventing yet another way to do something. Maybe just consolidate resources on an existing system. But then again this is talking to an ecosystem that develops hundreds of distros. Has anybody ever considered that maybe Linux on the desktop could be more appealing with fewer choices??

    Reply
    • “Has anybody ever considered that maybe Linux on the desktop could be more appealing with fewer choices??”

      Many people have. Unfortunately, none of them are in policy-making positions. Besides, there is the “everybody does their own thing” and “The more, the better” Linux philosophy.

      When it comes to Snaps, there is the additional factor of Canonical and Mark Shuttleworth wanting their own version of the software so they can control it. Mir, Unity, Snaps, and many other Canonical-only projects.

      “Maybe just consolidate resources on an existing system.”

      That’d be great. Linux could be better than Windows or OS/X. But then each Tom, Dick, and/or Harry out there would not get their 15 minutes of “fame”. The choice is Linux’s greatest strength but it is also its biggest Achilles’ heel.

      Reply
    • @Confused,

      To run an snap application from the terminal, just enter its absolute pathname, for example.

      $ /snap/bin/mailspring
      OR
      # /var/lib/snapd/snap/bin/mailspring
      
      Reply
  3. The article does not discuss a HUGE problem with snaps, and that’s the flexibility of the POSIX file system: I happen to have a home directory that I made a symlink to another mount point. It breaks most snaps, and with horrible error messages that are not even technically correct (claiming some directory doesn’t exist).

    I’ve read some comments that suggest the mount must have a bind option added but tried it.

    Btw, flatpak’s have similar issues, but they also have a tool call flatseal to work around it.

    Reply
    • @Peter

      This is a problem we had not experienced. We may consider adding a part to this guide which describes the disadvantages of using Snaps in Linux. But we have to compile different user feedback before updating the article. Many thanks for the useful feedback.

      Reply
  4. Snaps have the disadvantage that they tend to be massive compared with just installing the software using for example APT, Larger downloads, and more disk space is required which adds up to a larger resource requirement. I do not use Snaps or Flatpack except when there is no choice.

    Reply
    • @Dachshundman

      This is true – the fact the snaps are containerized apps, bundled with all their dependencies in a single package, they are massive (have larger download size) compared with just installing the software using, for example, APT or YUM or any of the popular Linux package managers. Thanks for adding your thoughts here.

      Reply
  5. We had a perfectly functional universal package manager in AppImage that could be used by all distros. But NOOO, Red Hat and Canonical decided that they want their own “universal” package managers that they can control and that they hope will take over the Linux Universe.

    So now we have three “universal” package managers. Somehow defeats the entire purpose of having one cross-distribution package manager. The choice is Linux’s greatest strength but it is also its greatest curse. It leads to every Tom, Dick, and Harry trying to reinvent the wheel.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.