(Last Updated On: November 17, 2018)

In this blog post, we will cover the steps to install and use snapd service on Fedora 29 & Fedora 28. 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.

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.

How to Install and Use Snapd on Fedora 29 / Fedora 28

Install Snapd on Fedora 29 / Fedora 28 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.36
Release     : 1.fc29
Architecture: x86_64
Install Date: Sat 17 Nov 2018 11:36:34 AM UTC
Group       : System Environment/Base
Size        : 53984174
License     : GPLv3
Signature   : RSA/SHA256, Sun 04 Nov 2018 05:14:04 PM UTC, Key ID a20aa56b429476b4
Source RPM  : snapd-2.36-1.fc29.src.rpm
Build Date  : Sun 04 Nov 2018 05:00:32 PM UTC
Build Host  : buildvm-32.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : https://github.com/snapcore/snapd
Bug URL     : https://bugz.fedoraproject.org/snapd
Summary     : A transactional software package manager
Description :
Snappy is a modern, cross-distribution, transactional package manager
designed for working with self-contained, immutable packages.

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
Usage:
  snap [OPTIONS] <command>

Install, configure, refresh and remove snap packages. Snaps are
'universal' packages that work across many different Linux systems,
enabling secure distribution of the latest apps and utilities for
cloud, servers, desktops and the internet of things.

This is the CLI for snapd, a background service that takes care of
snaps on the system. Start with 'snap list' to see installed snaps.


Application Options:
      --version  Print the version and exit

Help Options:
  -h, --help     Show this help message

Available commands:
  abort       Abort a pending change
  ack         Adds an assertion to the system
  alias       Sets up a manual alias
  aliases     Lists aliases in the system
  buy         Buys a snap
  changes     List system changes
  connect     Connects a plug to a slot
  disable     Disables a snap in the system
  disconnect  Disconnects a plug from a slot
  download    Downloads the given snap
  enable      Enables a snap in the system
  find        Finds packages to install (aliases: search)
  get         Prints configuration options
  help        Help
  info        show detailed information about a snap
  install     Installs a snap to the system
  interface   Lists snap interfaces
  interfaces  Lists interfaces in the system
  known       Shows known assertions of the provided type
  list        List installed snaps
  login       Authenticates on snapd and the store
  logout      Log out of the store
  logs        Retrieve logs of services
  pack        pack the given target dir as a snap
  prefer      Prefer aliases from a snap and disable conflicts
  refresh     Refreshes a snap in the system
  remove      Removes a snap from the system
  restart     Restart services
  revert      Reverts the given snap to the previous state
  run         Run the given snap command
  services    Query the status of services
  set         Changes configuration options
  start       Start services
  stop        Stop services
  switch      Switches snap to a different channel
  tasks       List a change's tasks (aliases: change)
  try         Tests a snap in the system
  unalias     Unalias a manual alias or an entire snap
  version     Shows version details
  watch       Watch a change in progress
  whoami      Prints the email the user is logged in with.

How to Install Snap Applications on CentOS 7

The snap command is used 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 Powershell from Snap Store.

# snap search powershell
Name                Version          Developer             Notes    Summary
powershell-preview  6.2.0-preview.2  microsoft-powershell  classic  PowerShell for every system!
powershell          6.1.1            microsoft-powershell  classic  PowerShell for every system!

Install snap by running:

$ sudo yum install -y icu
$ sudo snap install powershell --classic
powershell 6.1.1 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 6.1.1
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS /root>

To list installed snaps:

# snap list
Name        Version    Rev   Developer             Notes
core        16-2.35.5  5742  canonical             core
node        10.13.0    1266  nodesource            classic
powershell  6.1.1      14    microsoft-powershell  classic

Manually update snaps by running snap refresh

# 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:

# snap remove powershell
powershell removed

Check snap info:

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

[[email protected] ~]# snap info powershell
name:      powershell
summary:   PowerShell for every system!
publisher: microsoft-powershell
contact:   https://github.com/powershell/powershell
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/en-us/powershell/scripting/powershell-core-support
  for support details.
snap-id:     JSNnoJl3EqkMuWoy5Dgq8PMqZ0uNcpie
channels:              
  stable:    6.1.1 (8) 59MB classic
  candidate: 6.1.1 (8) 59MB classic
  beta:      6.1.1 (8) 59MB classic
  edge:      6.1.1 (8) 59MB classic

Roll back to a previous version of an application

Use snap revert

$ sudo snap revert <snap name>

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