Install Snapd and Snap applications on Fedora 36/35/34/33/32

Posted on 137 views

In this blog post, we will cover the steps to install and use snapd service on Fedora 36/35/34/33/32. Snappy is a package management and software deployment system from Canonical.

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.

install-snap-centos-7

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 Fedora36/35/34/33/32

Install Snapd on Fedora36/35/34/33/32 by executing the command below in your terminal.

sudo dnf -y install snapd

Wait for the installation to finish then confirm the version of snapd installed:

$ rpm -qi snapd
Name        : snapd
Version     : 2.55.3
Release     : 1.fc36
Architecture: x86_64
Install Date: Fri 10 Jun 2022 12:30:42 PM EAT
Group       : Unspecified
Size        : 49977223
License     : GPLv3
Signature   : RSA/SHA256, Mon 11 Apr 2022 04:24:16 PM EAT, Key ID 999f7cbf38ab71f4
Source RPM  : snapd-2.55.3-1.fc36.src.rpm
Build Date  : Mon 11 Apr 2022 04:08:17 PM EAT
Build Host  : buildvm-x86-20.iad2.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://github.com/snapcore/snapd
Bug URL     : https://bugz.fedoraproject.org/snapd
....

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  [...]

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 '.
For a short summary of all commands, run 'snap help --all'.

How to Install Snap Applications on Fedora

The snap command is used to interact with snaps available on Snap Store.

Searching for a snap:

To search for Snaps, use

$ snap find 

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 Powershell from Snap Store.

$ snap search powershell
Name                Version          Publisher              Notes    Summary
powershell          7.2.4            microsoft-powershell✓  classic  PowerShell for every system!
powershell-preview  7.3.0-preview.4  microsoft-powershell✓  classic  PowerShell for every system!
starship            1.6.3            matankushner           -        The minimal, blazing-fast, and infinitely customizable prompt for any shell!

Install snap by running:

$ sudo dnf install -y icu
$ sudo snap install powershell --classic
Setup snap "snapd" (16010) security profiles
2022-06-10T12:34:28+03:00 INFO Waiting for automatic snapd restart...
powershell 7.2.4 from Microsoft PowerShell✓ installed                                                                                                                                                   

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.2.4
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/jmutai>

To list installed snaps:

To list all installed snaps use the command:

$ snap list
Name        Version   Rev    Tracking       Publisher              Notes
core18      20220428  2409   latest/stable  canonical             base
powershell  7.2.4     208    latest/stable  microsoft-powershell  classic
snapd       2.56      16010  latest/stable  canonical             snapd

Manually update snaps by running snap refresh

Manually upgrade snap using refresh command:

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

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
  details.
commands:
  - powershell
snap-id:      JSNnoJl3EqkMuWoy5Dgq8PMqZ0uNcpie
tracking:     latest/stable
refresh-date: today at 12:34 EAT
channels:
  latest/stable:    7.2.4 2022-05-23 (208) 70MB classic
  latest/candidate: 7.2.1 2021-12-14 (193) 71MB classic
  latest/beta:      7.2.1 2021-12-14 (193) 71MB classic
  latest/edge:      7.2.1 2021-12-14 (193) 71MB classic
  lts/stable:       7.2.4 2022-05-23 (209) 70MB classic
  lts/candidate:    7.2.0 2021-11-09 (189) 71MB classic
  lts/beta:         7.2.0 2021-11-09 (189) 71MB classic
  lts/edge:         7.2.0 2021-11-09 (190) 71MB classic
installed:          7.2.4            (208) 70MB classic

Removing Snaps

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

$ snap remove powershell
powershell removed

Roll back to a previous version of an application

Use snap revert

$ snap revert 

Conclusion

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 memorable as possible. It should become second nature to you after using it just a couple of times.

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

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.