We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Install Snapd and Snap Applications on CentOS 7 / CentOS 8

Learn how to – Install Snapd and Snap Applications on CentOS 7 / CentOS 8.

In this guide, I’ll take you through the steps to install and use Snap on CentOS 8 / CentOS 7 server. For those new to snap terminology, snap comes from Snappy which is a package management and software deployment system from Canonical. It was originally designed for the Ubuntu phone operating system.

What is a snap?

snap :

  • is a squashFS filesystem containing your app code and a snap.yaml file containing specific metadata. It has a read-only file-system and, once installed, a writable area.
  • is self-contained. It bundles most of the libraries and runtimes it needs and can be updated and reverted without affecting the rest of the system.
  • is confined from the OS and other apps through security mechanisms, but can exchange content and functions with other snaps according to fine-grained policies controlled by the user and the OS defaults.

What is Snapd?

Snapd is a REST API daemon service that runs on your Linux system to manage snap packages (“snaps“). It interacts with the snap store and provides the command clientsnap used to interact with it. You must install snapd before you can start managing snaps on any Linux distribution.

Why use Snaps?

Snap packages any app for every Linux desktop, server, cloud or device. Snaps are faster to install, easier to create, safer to run, and they update automatically and transactionally so your app is always fresh and never broken. You can bring your own build infrastructure or use ours.

Install and Use Snapd on CentOS 8 / CentOS 7

Follow steps below to install Snapd on CentOS 7 / CentOS 8 Linux system.

Install Snapd on CentOS 8

Add EPEL repository

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y upgrade

Install Snap on CentOS 8

sudo dnf -y install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap

Install Snap on CentOS 7

Kick off the installation by adding epel repository and installing copr yum plugin.

sudo yum install epel-release
sudo yum install yum-plugin-copr

Then add the repo:

$ sudo yum copr enable ngompa/snapcore-el7

Loaded plugins: copr, fastestmirror

You are about to enable a Copr repository. Please note that this
repository is not part of the main Fedora distribution, and quality
may vary.

The Fedora Project does not exercise any power over the contents of
this repository beyond the rules outlined in the Copr FAQ at
<https://fedorahosted.org/copr/wiki/UserDocs#WhatIcanbuildinCopr>, and
packages are not held to any quality or securty level.

Please do not file bug reports about these packages in Fedora
Bugzilla. In case of problems, contact the owner of this repository.

Do you want to continue? [y/N]: y
copr done

Once the repository has been added, install snapd package.

sudo yum -y install snapd

Wait for the installation to finish then enable snapd socket:

$ sudo systemctl enable --now snapd.socket
Created symlink from /etc/systemd/system/sockets.target.wants/snapd.socket to /usr/lib/systemd/system/snapd.socket.

Classic confinement requires snaps under /snap or symlink from /snap to /var/lib/snapd/snap. Create a symlink for it like below:

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

Snapd is now ready for use. You interact with it using the snap command. See help page below:

$ snap --help
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap <command> [<options>...]

Commonly used commands can be classified as follows:

         Basics: find, info, install, remove, list
        ...more: refresh, revert, switch, disable, enable, create-cohort
        History: changes, tasks, abort, watch
        Daemons: services, start, stop, restart, logs
    Permissions: connections, interface, connect, disconnect
  Configuration: get, set, unset, wait
    App Aliases: alias, aliases, unalias, prefer
        Account: login, logout, whoami
      Snapshots: saved, save, check-snapshot, restore, forget
         Device: model, reboot, recovery
      ... Other: warnings, okay, known, ack, version
    Development: download, pack, run, try

For more information about a command, run 'snap help <command>'.
For a short summary of all commands, run 'snap help --all'.

Install Snap Applications on CentOS 7 / CentOS 8

We use snap command line tool to interact with snaps available on Snap Store.

Searching for a snap:

To search for Snaps, use

$ snap find <search terms>

This will query the store and list the results with their version number, developer names, and the description.

I’ll do an example for installation of Microsoft PowerShell automation and configuration management platform on CentOS 7 server.

$ snap search powershell
Name                Version          Publisher              Notes    Summary
powershell          7.3.4            microsoft-powershell✓  classic  PowerShell for every system!
powershell-preview  7.4.0-preview.3  microsoft-powershell✓  classic  PowerShell for every system!
starship            1.14.2           matankushner           -        The minimal, blazing-fast, and infinitely customizable prompt for any shell!
portal              1.2.3            zinokader              -        Quick and easy command-line file transfer utility from any computer to another.

Install snap by running:

sudo yum install -y icu
sudo snap install powershell --classic

Wait for the download to finish, it should take short time to complete. Since the binary file is located under,/snap/bin/ we need to add this to the $PATHvariable.

$ sudo vim /etc/profile
export PATH="$PATH:/snap/bin/"

Source the file to get new PATH

source /etc/profile

Test by starting the pwshsession.

# pwsh 
PowerShell 7.3.4
Copyright (c) Microsoft Corporation. All rights reserved.

Type 'help' to get help.

PS /root>

To list installed snaps:

$ snap list
Name        Version   Rev    Tracking       Publisher              Notes
core20      20230503  1891   latest/stable  canonical✓             base
powershell  7.3.4     234    latest/stable  microsoft-powershell✓  classic
snapd       2.59.4    19361  latest/stable  canonical✓             snapd

Manually update snaps by running snap refresh

$ sudo snap refresh powershell 
snap "powershell" has no updates available

Removing Snaps

To remove a snap, all you need to do is run.snap remove <snap name>  In our case just do:

$ sudo snap remove powershell
powershell removed

Check snap info:

Use the command snap info to check for more info about a snap package.

$ snap info powershell
name:      powershell
summary:   PowerShell for every system!
publisher: Microsoft PowerShell✓
store-url: https://snapcraft.io/powershell
contact:   https://github.com/powershell/powershell
license:   unset
description: |
  PowerShell is an automation and configuration management platform.
  It consists of a cross-platform (Windows, Linux, and macOS)
  command-line shell and associated scripting language.

  See https://docs.microsoft.com/powershell/scripting/powershell-support-lifecycle for support
  - powershell
snap-id:      JSNnoJl3EqkMuWoy5Dgq8PMqZ0uNcpie
tracking:     latest/stable
refresh-date: today at 21:28 UTC
  latest/stable:    7.3.4  2023-04-20 (234) 74MB classic
  latest/candidate: ↑
  latest/beta:      ↑
  latest/edge:      ↑
  lts/stable:       7.2.11 2023-04-20 (235) 72MB classic
  lts/candidate:    7.2.8  2022-12-13 (227) 71MB classic
  lts/beta:         7.2.8  2022-12-13 (227) 71MB classic
  lts/edge:         7.2.8  2022-12-13 (227) 71MB classic
installed:          7.3.4             (234) 74MB classic

Roll back to a previous version of an application

Use snap revert

$ sudo snap revert <snap name>


By now you should be able to install snaps the store, manually update them, remove them, check installed snaps and much more. The snap command line is designed to be as simple and memorisable as possible. It should become a second nature to you after using it just a couple of times.

Another example which uses a snap for installation is How to Install Wekan Open source Kanban on CentOS 7 with Nginx and Letsencrypt SSL.


Your Cart is Empty

Back To Shop