How to install Snap on Linux 9

Share on Social Media

In this Linux tutorial, you will learn how to install Snap on Linux 9 or other Red Hat based Linux distributions. #centlinux #linux #snapstore

What is Snap?:

Snap is a software packaging and deployment system, developed by Canonical for operating systems that use the Linux kernel and the systemd init system. The packages, called snaps, and the tool for using them, snapd, work across a range of Linux distributions and allow upstream software developers to distribute their applications directly to users. Snaps are self-contained applications running in a sandbox with mediated access to the host system. Snap was originally released for cloud applications but was later ported to also work for Internet of Things devices and desktop applications. (Source: Wikipedia)

Snaps are packaged with all their dependencies to run on all popular Linux distributions from a single build. They update automatically and roll back gracefully.

Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.

Video to install Snap on Linux:

YouTube player

Features of Snap Software:

Some of the most popular features of Snap software are:

  • Snap Store: The Snap Store allows developers to publish their snap-packaged applications. All apps uploaded to the Snap Store undergo automatic testing, including a malware scan.
  • Universal Linux Packages: Snaps are self-contained packages that work across a range of Linux distributions. This is unlike traditional Linux package management approaches, which require specifically adapted packages for each Linux distribution.
  • Configurable Sandbox: Applications in a Snap run in a container with limited access to the host system. Using Interfaces, users can give an application mediated access to additional features of the host such as recording audio, accessing USB devices and recording video. These interfaces mediate regular Linux APIs so that applications can function in the sandbox without needing to be rewritten. Desktop applications can also use the XDG Desktop Portals, a standardized API originally created by the Flatpak project to give sandboxed desktop applications access to host resources.
  • Automatic and Atomic Updates: Multiple times a day, snapd checks for available updates of all Snaps and installs them in the background using an atomic operation. Updates can be reverted and use delta encoding to reduce their download size.
  • Snapcraft: Snapcraft is a tool for developers to package their programs in the Snap format. It runs on any Linux distribution supported by Snap, macOS and Microsoft Windows. Snapcraft builds the packages in a Virtual Machine using Multipass, in order to ensure the result of a build is the same, regardless of which distribution or operating system it is built on. Snapcraft supports multiple build tools and programming languages, such as Go, Java, JavaScript, Python, C/C++ and Rust. It also allows importing application metadata from multiple sources such as AppStream, git, shell scripts and setup.py files.

Environment Specification:

We are using a virtual machine with minimal Rocky Linux 9 OS with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – Rocky Linux release 9.1 (Blue Onyx)
  • Hostname – rocky-01.centlinux.com
  • IP Address – 192.168.116.128/24

Preparing your Linux Server:

By using a ssh tool, login as root user on your Rocky Linux server.

Execute dnf command to update software packages in your Linux OS.

# dnf update -y

Snap software is available in EPEL (Extra Packages for Enterprise Linux) yum repository. Therefore, you should install it now by executing following command.

# dnf install -y epel-release

EPEL repository is dependent upon CRB (CodeReady Builder) yum repository. Therefore, you need to enable it before installing Snap software.

# /usr/bin/crb enable
Enabling CRB repo
CRB repo is enabled and named: crb

Rebuild your cache for newly installed yum repositories.

# dnf makecache
Extra Packages for Enterprise Linux 9 - x86_64  515 kB/s |  15 MB     00:30
Rocky Linux 9 - BaseOS                          816  B/s | 4.1 kB     00:05
Rocky Linux 9 - AppStream                       857  B/s | 4.5 kB     00:05
Rocky Linux 9 - CRB                             372 kB/s | 2.1 MB     00:05
Rocky Linux 9 - Extras                          737  B/s | 2.9 kB     00:04
Metadata cache created.

All required yum repositories has been setup. Now, you can easily install snap software.

Install Snapd on Linux Server:

To setup Snap software on your Linux OS, you need to install snapd software package.

Search for snapd by using dnf command.

# dnf search snapd
Last metadata expiration check: 0:00:30 ago on Sat 13 May 2023 08:11:20 PM PKT.
========================= Name Exactly Matched: snapd ==========================
snapd.x86_64 : A transactional software package manager
======================== Name & Summary Matched: snapd =========================
snapd-devel.noarch : Development files for snapd
snapd-glib.x86_64 : Library providing a GLib interface to snapd
snapd-glib-devel.x86_64 : Development files for snapd-glib
snapd-glib-tests.x86_64 : Installed tests for snapd-glib
snapd-qt.x86_64 : Library providing a Qt5 interface to snapd
snapd-qt-devel.x86_64 : Development files for snapd-qt
snapd-qt-qml.x86_64 : Library providing a Qt5 QML interface to snapd
snapd-qt-tests.x86_64 : Installed tests for snapd-qt
snapd-selinux.noarch : SELinux module for snapd

Install snapd software package by executing following command.

# dnf install -y snapd

Enable and start snapd.socket by running following command at Linux terminal.

# systemctl enable --now snapd.socket
Created symlink /etc/systemd/system/sockets.target.wants/snapd.socket → /usr/lib/systemd/system/snapd.socket.

To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap directories.

# ln -s /var/lib/snapd/snap /snap

Snap environment variables are not set for your current session. Therefore, obtain a new Linux Bash shell by using su command.

# su -

Install Snap on Linux:

To install Snap on Linux, simply run the following command at Linux terminal.

# snap install snap-store
snap-store 41.3-71-g709398e from Canonical✓ installed

To get the list of installed snaps, you can execute following command.

# snap list
Name               Version           Rev    Tracking       Publisher        Notes
snap-store         41.3-71-g709398e  959    latest/stable  canonical✓       -

You can get more details about a snap as follows.

# snap info snap-store
name:    snap-store
summary: Snap Store is a graphical desktop application for discovering,
  installing and managing snaps on Linux.
publisher: Canonical✓
store-url: https://snapcraft.io/snap-store
contact:   https://bugs.launchpad.net/snap-store/
license:   unset
description: |
  Snap Store showcases featured and popular applications with useful
  descriptions, ratings, reviews and screenshots.


  Applications can be found either through browsing categories
  or by searching.


  Snap Store can also be used to switch channels, view and alter snap
  permissions and view and submit reviews and ratings.


  Snap Store is based on GNOME Software, optimized for the Snap experience.
commands:
  - snap-store
  - snap-store.ubuntu-software
  - snap-store.ubuntu-software-local-file
snap-id:      gjf3IPXoRiipCu9K0kVu52f0H56fIksg
tracking:     latest/stable
refresh-date: today at 22:26 PKT
channels:
  latest/stable:     41.3-71-g709398e 2023-04-28 (959) 12MB -
  latest/candidate:  41.3-71-g709398e 2023-04-27 (959) 12MB -
  latest/beta:       ↑
  latest/edge:       41.3-71-g709398e 2023-03-29 (959) 12MB -
  preview/stable:    –
  preview/candidate: 0.2.7-alpha      2023-02-02 (864) 10MB -
  preview/beta:      ↑
  preview/edge:      0.2.9-alpha      2023-05-09 (965) 10MB -
installed:           41.3-71-g709398e            (959) 12MB -

To update all installed snaps, you can execute following command at Linux terminal.

# snap refresh
All snaps up to date.

Conclusion – Install Snap on Linux:

In this Linux tutorial, you have learned how to install snap on Linux 9 or other Red Hat based Linux distributions. If you are new to Linux command-line, then we strongly recommend that you should attend online training: Linux command line for beginners