0% found this document useful (0 votes)
53 views1 page

36 Popular Snap Command Examples in Linux For Beginners - CyberITHub

Uploaded by

Roel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views1 page

36 Popular Snap Command Examples in Linux For Beginners - CyberITHub

Uploaded by

Roel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Home Contact Us About Me Privacy Policy Sponsored Post

Cloud Database Programming Scripting DevOps Interview Questions

MORE

36 Popular Snap command examples in


Linux for Beginners
June 15, 2021 by cyberithub

Categories Table of Contents

Ansible Synopsis
Snap command examples in Linux
AWS Example 1: How to Check Snap command version
Azure Example 2: How to Install a Snap
Example 3: How to Update a snap
Bash
Example 4: How to Remove a Snap
C Example 5: How to List all the available Updates
Example 6: How to List all the Installed Snaps
C#
Example 7: How to Install a Snap using different Channel
C++ Example 8: How to Check all the information about a Snap
Example 9: How to find a package using snap command
Chef
Example 10: How to revert back a Snap version
Cloud Example 11: How to Disable a Installed Snap
Example 12: How to Enable a Installed Snap
Database
Example 13: How to Remove a Snap from System
DevOps Example 14: How to List all the revisions of a Snap
Example 15: How to List all the Snap Changes
Docker
Example 16: How to List all Interface Connections of a Snap
Docker Example 17: How to only download a Snap

ELK Example 18: How to Check Snap Model Details


Example 19: How to Check a Snap Service
Git Example 20: How to Restart a Snap Service

GO Example 21: How to Stop a Snap Service


Example 22: How to Start a Snap Service
Google Example 23: How to Check Logs of a Service
HTML Example 24: How to Create an Alias of a Snap
Example 25: How to Generate Snapshot for all Installed Snaps
Interview Example 26: How to Verify a Snapshot
Questions Example 27: How to Restore a Snapshot

Java Example 28: How to Delete a Snapshot


Example 29: How to Query a Specific Snapshot
JavaScript Example 30: How to List all the Aliases
Kubernetes Example 31: How to Remove an Alias for a Snap
Example 32: How to authenticate User to snapd and snap store
Linux Example 33: How to Log out from snapd and snap store
macOS Example 34: How to Remove a Snap without generating snapshot
Example 35: How to Check all the options available with snap
Monitoring command
MORE Example 36: How to Check Man Page of snap command Recent Posts
MYSQL
In this article, I will take you through 36 Popular Snap Command
Networking How to Install
examples in Linux. A snap is a bundle of an app and its dependencies
Flutter on Ubuntu
Node.js that works without modification across many different Linux
22.04 LTS (Jammy
distributions. The packages, are usually called ‘snaps’ and the tool
Openstack Jellyfish)
for using them is called ‘snapd’, which works across a range of Linux
Oracle distributions and therefore allows cross platform deployment. How to Install curl
Perl command on
Snapd is basically the daemon service which manages the snap Ubuntu 22.04 LTS
PHP packages. Snap command works more or less like apt or apt-get (Jammy Jellyfish)
PostgreSQL command on Ubuntu. You can securely install snaps in multiple Linux
distribution platforms. Snap utility also allows you to download
How to Install
Powershell multiple versions of the same package, thus providing a unique pacman package
Programming feature as compared to other utilities. More on Snapcraft. manager on
Ubuntu 22.04 LTS
Puppet
Synopsis How to Install zlib
Python
package on
snap [OPTIONS]
Redis Ubuntu 22.04 LTS
Ruby (Jammy Jellyfish)

Scripting How to Install


AnyDesk on
Security
Windows 10 Using
Solaris 3 Easy Steps
Terraform How to Install
Windows Microsoft InfoPath
2013 on Windows
10

How to Install and


Use Lombok in
Java Eclipse IDE
Snap command examples in Linux
How to Install Tera
Also Read: 6 Easy Steps to Install Postman on Ubuntu 20.04 Term on Windows
10 Using 4 Simple
Example 1: How to Check Snap command version
Steps

To check the snap utility version, you need to use snap --version How to Install
command as shown below. Meld on Ubuntu
20.04 LTS (Focal
Fossa)
root@localhost:~# snap --version
snap 2.50.1 How to Install
snapd 2.50.1 pgAdmin 4 on
series 16
Ubuntu 20.04 LTS
ubuntu 20.04
kernel 5.8.0-55-generic (Focal Fossa)

Example 2: How to Install a Snap


Recent
Comments
If you want to install a snap then you need to use snap install
<snap_name> syntax. In this example, we are installing postman
Hassan on Solved
using snap install postman command as shown below.
"WslRegisterDistri
bution failed with
root@localhost:~# snap install postman error:
postman (v8/stable) 8.5.1 from Postman, Inc. (postman- 0x80370114"
Codam on Solved
"User is not in the
sudoers file. This
Example 3: How to Update a snap incident will be
reported"
If you want to update a snap to the latest version then you need to
use snap refresh <snap_name> syntax. In this example, we are
John on How to
updating chromium to the latest version by using snap refresh Install the latest
chromium command as shown below. version of Node.js
on Ubuntu/Debian
yk on Solved
root@localhost:~# snap refresh chromium
"WslRegisterDistri
chromium 91.0.4472.101 from Canonical* refreshed
bution failed with
error:
0x80370114"
Example 4: How to Remove a Snap deephazra on
Solved "syntax
If you want to remove a snap then you need to use snap remove
error: unexpected
<snap_name> syntax. In this example, we are removing postman
end of File" in
using snap remove postman command as displayed below.
Linux Shell
Scripting
root@localhost:~# snap remove postman deep hazra on
postman removed
How to Install
netcat(nc)
command on Linux
(RedHat/CentOS
Example 5: How to List all the available Updates
7/8) in 5 Easy
If you want to list all the available snap updates then you need to Steps
use snap refresh --list command as shown below.
Andrii on Solved
"WslRegisterDistri
bution failed with
root@localhost:~# snap refresh --list
Name Version Rev Publisher Notes error:
chromium 91.0.4472.101 1628 canonical* - 0x80370114"

AiOGajo on
[Solved]: -bash:
/etc/iptables/iptab
Example 6: How to List all the Installed Snaps
les.rules: No such
You can use snap list command to list all the installed snaps in file or directory
your System as shown below.
Ian on How to
Install QEMU on
Ubuntu 20.04 LTS
root@localhost:~# snap list
Name Version Rev Tracking Publisher Notes (Focal Fossa)
chromium 91.0.4472.101 1628 latest/stable canonical* -
polina on Solved
core 16-2.50.1 11167 latest/stable canonical* core
core18 20210507 2066 latest/stable canonical* base "git add shows
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 145 latest/ unable to index
gnome-3-34-1804 0+git.3556cb3 72 latest/stable/… canon
file Permission
gtk-common-themes 0.1-52-gb92ac40 1515 latest/stable/…
postman 8.5.1 140 v8/stable postman-inc* - denied" error
snap-store 3.38.0-63-g766b86f 542 latest/stable/… cano
snapd 2.50.1 12057 latest/stable canonical* snapd

LET’S
KEEP
Example 7: How to Install a Snap using different Channel IN
There are multiple different channels available through which you
TOUC
can install a Snap. It is stable, edge, beta and candidate. By
H!
default when we install a snap, it gets installed from stable We’d love
to keep
channel. you
updated
In this example, we are installing postman through multiple with our
latest
different channel. If you want to install postman through edge
articles
channel then you need to use snap install --edge postman
command as displayed below.
First
Name *
root@localhost:~# snap install --edge postman First Nam
postman (v8/edge) 8.5.1 from Postman, Inc. (postman-in

Last
Name
If you want to install postman through beta channel, then you need
to use snap install --beta postman command as shown below. Last Nam

Email
root@localhost:~# snap install --beta postman Address
postman (v8/stable) 8.5.1 from Postman, Inc. (postman- *
Channel v8/beta for postman is closed; temporarily for
Email Ad

Finally, if you want to install postman through candidate channel


Keep me po
then you need to use snap install --candidate postman
command as shown below.
We don’t
spam! Read
our privacy
root@localhost:~# snap install --candidate postman policy for
postman (v8/stable) 8.5.1 from Postman, Inc. (postman- more info.
Channel v8/candidate for postman is closed; temporaril

Example 8: How to Check all the information about a Snap

If you want to see complete information about a snap then you need
to use snap info <snap_name> syntax. In this example, we are
listing all the information about postman using snap info postman
command as shown below.

root@localhost:~# snap info postman


name: postman
summary: API Development Environment
publisher: Postman, Inc. (postman-inc*)
store-url: https://snapcraft.io/postman
contact: https://github.com/postmanlabs/postman-app-su
license: unset
description: |
Postman is the collaboration platform for API developm
400,000 companies worldwide. Postman is an elegant, fl
via APIs quickly, easily, and accurately. Postman is a
Francisco, a large office in Bangalore (where the comp
members on four continents. Postman is privately held,
and CRV.
commands:
- postman
snap-id: fFcOtEEF4EdyYb95IUE5Isy28tICYMLf
tracking: v8/candidate
refresh-date: today at 19:27 IST

Example 9: How to find a package using snap command

If you want to find a snap, then you need to use snap find
<snap_name> syntax to find that snap. In this example, we are
looking for postman using snap find postman command as
displayed below.

root@localhost:~# snap find postman


Name Version Publisher Notes Summary
postman 8.5.1 postman-inc* - API Development Environm

Example 10: How to revert back a Snap version

Sometimes updating a snap to the latest version might create


certain issues so in that case it is always better to revert back to the
old version. You can simply use snap revert <snap_name>
command to revert back to the old version. In this example, we are
reverting chromium back to the old version by using snap revert
chromium command as displayed below.

root@localhost:~# snap revert chromium


chromium reverted to 91.0.4472.77

Example 11: How to Disable a Installed Snap

In case you don't want to use a snap, you can simply disable it by
using snap disable <snap_name> syntax. In this example, we are
disabling postman snap using snap disable postman command.

root@localhost:~# snap disable postman


postman disabled

Example 12: How to Enable a Installed Snap

In case you want to enable the disabled snap then you need to use
snap enable <snap_name> syntax. In this example, we are
enabling the disabled snap postman using snap enable postman
command as shown below.

root@localhost:~# snap enable postman


postman enabled

Example 13: How to Remove a Snap from System

If you want to remove a snap from System then you need to use
snap remove postman command as displayed below.

root@localhost:~# snap remove postman


postman removed

Example 14: How to List all the revisions of a Snap

If you want to check all the available revisions of a snap then you
need to use snap list --all <snap_name> syntax. In this
example, we are checking all the revisions of chromium using snap
list --all chromium command as shown below.

root@localhost:~# snap list --all chromium


Name Version Rev Tracking Publisher Notes
chromium 91.0.4472.77 1608 latest/stable canonical* -
chromium 91.0.4472.1011628 latest/stable canonical* di

Example 15: How to List all the Snap Changes

You can also check all the snap operations you have done using snap
changes command as displayed below.

root@localhost:~# snap changes


ID Status Spawn Ready Summary
10 Done yesterday at 21:57 IST yesterday at 21:58 IST
11 Done yesterday at 21:59 IST yesterday at 22:00 IST
12 Done today at 12:40 IST today at 12:40 IST Remove "
13 Done today at 12:42 IST today at 12:42 IST Install
14 Done today at 12:47 IST today at 12:47 IST Refresh
15 Done today at 19:25 IST today at 19:26 IST Remove "
16 Done today at 19:26 IST today at 19:26 IST Install

Example 16: How to List all Interface Connections of a Snap

To list all the interface connections of a snap, you need to use snap
connections <snap_name> syntax. In this example, we are listing
all interface connections of postman snap using snap connections
postman command as displayed below.

root@localhost:~# snap connections postman


Interface Plug Slot Notes
browser-support postman:browser-support :browser-suppo
desktop postman:desktop :desktop -
desktop-legacy postman:desktop-legacy :desktop-legacy
gsettings postman:gsettings :gsettings -
home postman:home :home -
network postman:network :network -

Example 17: How to only download a Snap

If you do not want to install a snap and only want to download that
snap then you can use snap download <snap_name> syntax. In this
example, we are downloading postman snap using snap download
postman command as shown below.

root@localhost:~# snap download postman


Fetching snap "postman"
Fetching assertions for "postman"
Install the snap with:
snap ack postman_140.assert
snap install postman_140.snap
root@localhost:~# ls -ltr postman_140.snap
-rw------- 1 root root 198053888 Jun 11 21:16 postman_

Example 18: How to Check Snap Model Details

If you want to check snap model details then you need to use snap
model command as shown below.

root@localhost:~# snap model


brand Generic*
model generic-classic
serial dc38ee16-9c5f-4eca-9b48-f67cd8a36006

Example 19: How to Check a Snap Service

If you want to check the current status of a service, then you can use
snap services <service> syntax. In this example, we are
checking the status of lxd service using snap services lxd
command as shown below.

root@localhost:~# snap services lxd


Service Startup Current Notes
lxd.activate enabled inactive -
lxd.daemon enabled inactive socket-activated

Example 20: How to Restart a Snap Service

If you want to restart a snap service then you need to use snap
restart <service_name> syntax. In this example, we are
restarting lxd service using snap restart lxd command as
displayed below.

root@localhost:~# snap restart lxd


Restarted.

Example 21: How to Stop a Snap Service

If you want to stop a snap service then the syntax you need to use is
snap stop <service_name>. In this example, we are stopping lxd
service using snap stop lxd command as displayed below.

root@localhost:~# snap stop lxd


Stopped.

Example 22: How to Start a Snap Service

To start a snap service, you need to use snap start


<service_name> syntax. In this example, we are starting lxd service
by using snap start lxd command as shown below.

root@localhost:~# snap start lxd


Started.

Example 23: How to Check Logs of a Service

If you want to check the logs of a service, then you need to use snap
logs <service_name> syntax. In this example, we are checking the
logs of lxd service by using snap logs lxd command as shown
below.

root@localhost:~# snap logs lxd


2021-06-11T15:56:50Z systemd[1]: snap.lxd.daemon.servi
2021-06-11T15:56:50Z systemd[1]: Stopped Service for s
2021-06-11T15:56:55Z systemd[1]: Starting Service for
2021-06-11T15:56:55Z lxd.activate[7193]: => Starting L
2021-06-11T15:56:55Z lxd.activate[7193]: ==> Loading s
2021-06-11T15:56:56Z lxd.activate[7193]: ==> Checking
2021-06-11T15:56:56Z lxd.activate[7193]: ==> Setting L
2021-06-11T15:56:56Z lxd.activate[7193]: ==> Checking
2021-06-11T15:56:56Z systemd[1]: snap.lxd.activate.ser
2021-06-11T15:56:56Z systemd[1]: Finished Service for

Example 24: How to Create an Alias of a Snap

If you want to create an alias of a snap then the syntax you need to
use is snap alias <snap_name> <snap_alias>. In this example,
we are creating alias of chromium using snap alias chromium
chro command as displayed below. Here chro is the alias of
chromium.

root@localhost:~# snap alias chromium chro


Added:
- chromium as chro

Example 25: How to Generate Snapshot for all Installed Snaps

In case you want to take the snapshot of all the installed snaps, then
you need to use snap save command as displayed below.

root@localhost:~# snap save


Set Snap Age Version Rev Size Notes
8 chromium 1.12s 91.0.4472.77 1608 80.0kB -
8 core 1.40s 16-2.50.1 11167 125B -
8 core18 668ms 20210507 2066 123B -
8 gnome-3-28-1804 1.19s 3.28.0-19-g98f9e67.98f9e67 145
8 gnome-3-34-1804 574ms 0+git.3556cb3 72 124B -
8 gtk-common-themes 998ms 0.1-52-gb92ac40 1515 123B -
8 lxd 883ms 4.15 20638 30.2kB -
8 postman 497ms 8.5.1 140 123B -
8 snap-store 1.36s 3.38.0-63-g766b86f 542 80.0kB -
8 snapd 728ms 2.50.1 12057 125B -

Example 26: How to Verify a Snapshot

After taking a snapshot, you can also verify it by using snap check-
snapshot <snapshot-id> syntax. In this example, we are verifying
snapshot Id 8 by using snap check-snapshot 8 command as shown
below.

root@localhost:~# snap check-snapshot 8


Snapshot #8 verified successfully.

Example 27: How to Restore a Snapshot

If you are planning to restore a snapshot then you need to use snap
restore <snap_id> syntax. In this example, we are restoring
Snapshot ID 8 using snap restore 8 command as shown below.

root@localhost:~# snap restore 8


Restored snapshot #8.

Example 28: How to Delete a Snapshot

If you want to delete a snapshot then you need to use snap forget
<snapshot_Id> syntax. In this example, we are deleting snapshot of
ID 8 using snap forget 8 command as shown below.

root@localhost:~# snap forget 8


Snapshot #8 forgotten.

Example 29: How to Query a Specific Snapshot

If you want to query a specific snapshot then you need to use snap
saved --id=<snapshot_id> syntax. In this example, we are
querying Snapshot ID 9 using snap saved --id=9 command as
shown below.

root@localhost:~# snap saved --id=9


Set Snap Age Version Rev Size Notes
9 chromium 25.0s 91.0.4472.77 1608 80.0kB -
9 core 24.7s 16-2.50.1 11167 125B -
9 core18 24.8s 20210507 2066 123B -
9 gnome-3-28-1804 24.8s 3.28.0-19-g98f9e67.98f9e67 145
9 gnome-3-34-1804 24.7s 0+git.3556cb3 72 124B -
9 gtk-common-themes 24.9s 0.1-52-gb92ac40 1515 123B -
9 lxd 24.9s 4.15 20638 30.2kB -
9 postman 24.8s 8.5.1 140 123B -
9 snap-store 24.9s 3.38.0-63-g766b86f 542 80.0kB -
9 snapd 24.8s 2.50.1 12057 125B -

Example 30: How to List all the Aliases

To list all the snap aliases, you need to use snap aliases command
as displayed below.

root@localhost:~# snap aliases


Command Alias Notes
chromium chro manual
lxd.lxc lxc -

Example 31: How to Remove an Alias for a Snap

If you want to remove an alias of a snap then you need to first find
that alias from snap aliases command. Then you can remove it by
using snap unalias <snap_alias> syntax. In this example, we are
removing alias of chromium snap by using snap unalias chro
command as shown below.

root@localhost:~# snap unalias chro


Removed:
- chromium as chro

Example 32: How to authenticate User to snapd and snap store

In case you want to login to snapd and snap store, you can use snap
login command and provide your valid Email ID and password to
authenticate.

root@localhost:~# snap login


Personal information is handled as per our privacy not
https://www.ubuntu.com/legal/dataprivacy/snap-store

Email address:

Example 33: How to Log out from snapd and snap store

To log out from snapd and snap store, you can use snap logout
command as shown below.

root@localhost:~# snap logout

Example 34: How to Remove a Snap without generating snapshot

If you want to remove a snap without generating snapshot then you


need to use --purge option with snap remove command. In this
example, we are removing postman without generating snapshot by
using snap remove postman --purge command as displayed
below.

root@localhost:~# snap remove postman --purge


postman removed

Example 35: How to Check all the options available with snap
command

If you want to check all the options available with snap command,
then you need to use snap --help command as shown below.

root@localhost:~# snap --help


The snap command lets you install, configure, refresh
Snaps are packages that work across many different Lin
enabling secure delivery and operation of the latest a

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

Commonly used commands can be classified as follows:

Basics: find, info, install, remove, list


...more: refresh, revert, switch, disable, enable, cre
History: changes, tasks, abort, watch
Daemons: services, start, stop, restart, logs
Permissions: connections, interface, connect, disconne
Configuration: get, set, unset, wait
App Aliases: alias, aliases, unalias, prefer

Example 36: How to Check Man Page of snap command

If you want to check the Man page of snap command, then you need
to use man snap command as displayed below.

root@localhost:~# man snap


snap(8) System Manager's Manual snap(8)

NAME
snap - Tool to interact with snaps

SYNOPSIS
snap [OPTIONS]

DESCRIPTION
The snap command lets you install, configure, refresh
enabling secure delivery and operation of the latest a

OPTIONS
COMMANDS
abort
Abort a pending change

The abort command attempts to abort a change that stil

Usage: snap abort [abort-OPTIONS]

MORE, Linux

6 Easy Steps to Install 5 Best Steps to Install Snap


Postman on Ubuntu 20.04 command on Ubuntu 20.04

Leave a Comment

Name *

Email *

Website

Save my name, email, and website in this browser for the next
time I comment.

Post Comment

Copyright © 2023 | Hosted By Rocket

You might also like