Table of Contents
In this article, I will take you through 36 Popular Snap Command examples in Linux. A snap is a bundle of an app and its dependencies that works without modification across many different Linux distributions. The packages, are usually called ‘snaps’ and the tool for using them is called ‘snapd’, which works across a range of Linux distributions and therefore allows cross platform deployment.
Snapd is basically the daemon service which manages the snap packages. Snap command works more or less like apt or apt-get command on Ubuntu. You can securely install snaps in multiple Linux distribution platforms. Snap utility also allows you to download multiple versions of the same package, thus providing a unique feature as compared to other utilities. More on Snapcraft.
Synopsis
snap [OPTIONS]
Snap command examples in Linux
Also Read: 6 Easy Steps to Install Postman on Ubuntu 20.04
Example 1: How to Check Snap command version
To check the snap utility version, you need to use snap --version
command as shown below.
root@localhost:~# snap --version snap 2.50.1 snapd 2.50.1 series 16 ubuntu 20.04 kernel 5.8.0-55-generic
Example 2: How to Install a Snap
If you want to install a snap then you need to use snap install <snap_name>
syntax. In this example, we are installing postman using snap install postman
command as shown below.
root@localhost:~# snap install postman postman (v8/stable) 8.5.1 from Postman, Inc. (postman-inc*) installed
Example 3: How to Update a snap
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 updating chromium to the latest version by using snap refresh chromium
command as shown below.
root@localhost:~# snap refresh chromium chromium 91.0.4472.101 from Canonical* refreshed
Example 4: How to Remove a Snap
If you want to remove a snap then you need to use snap remove <snap_name>
syntax. In this example, we are removing postman using snap remove postman
command as displayed below.
root@localhost:~# snap remove postman postman removed
Example 5: How to List all the available Updates
If you want to list all the available snap updates then you need to use snap refresh --list
command as shown below.
root@localhost:~# snap refresh --list Name Version Rev Publisher Notes chromium 91.0.4472.101 1628 canonical* -
Example 6: How to List all the Installed Snaps
You can use snap list
command to list all the installed snaps in your System as shown below.
root@localhost:~# snap list Name Version Rev Tracking Publisher Notes chromium 91.0.4472.101 1628 latest/stable canonical* - core 16-2.50.1 11167 latest/stable canonical* core core18 20210507 2066 latest/stable canonical* base gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 145 latest/stable canonical* - gnome-3-34-1804 0+git.3556cb3 72 latest/stable/… canonical* - gtk-common-themes 0.1-52-gb92ac40 1515 latest/stable/… canonical* - postman 8.5.1 140 v8/stable postman-inc* - snap-store 3.38.0-63-g766b86f 542 latest/stable/… canonical* - snapd 2.50.1 12057 latest/stable canonical* snapd
Example 7: How to Install a Snap using different Channel
There are multiple different channels available through which you can install a Snap. It is stable
, edge
, beta
and candidate
. By default when we install a snap, it gets installed from stable
channel.
In this example, we are installing postman through multiple different channel. If you want to install postman through edge channel then you need to use snap install --edge postman
command as displayed below.
root@localhost:~# snap install --edge postman postman (v8/edge) 8.5.1 from Postman, Inc. (postman-inc*) installed
If you want to install postman through beta channel, then you need to use snap install --beta postman
command as shown below.
root@localhost:~# snap install --beta postman postman (v8/stable) 8.5.1 from Postman, Inc. (postman-inc*) installed Channel v8/beta for postman is closed; temporarily forwarding to v8/stable.
Finally, if you want to install postman through candidate channel then you need to use snap install --candidate postman
command as shown below.
root@localhost:~# snap install --candidate postman postman (v8/stable) 8.5.1 from Postman, Inc. (postman-inc*) installed Channel v8/candidate for postman is closed; temporarily forwarding to v8/stable.
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-support/issues license: unset description: | Postman is the collaboration platform for API development, used by 8 million developers and 400,000 companies worldwide. Postman is an elegant, flexible tool for building connected software via APIs quickly, easily, and accurately. Postman is a global company with headquarters in San Francisco, a large office in Bangalore (where the company was founded), and distributed team members on four continents. Postman is privately held, with funding from Nexus Venture Partners 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 Environment
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* disabled
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 Remove "postman" snap 11 Done yesterday at 21:59 IST yesterday at 22:00 IST Install "postman" snap 12 Done today at 12:40 IST today at 12:40 IST Remove "postman" snap 13 Done today at 12:42 IST today at 12:42 IST Install "postman" snap 14 Done today at 12:47 IST today at 12:47 IST Refresh "chromium" snap 15 Done today at 19:25 IST today at 19:26 IST Remove "postman" snap 16 Done today at 19:26 IST today at 19:26 IST Install "postman" snap from "edge" channel
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-support - 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_140.snap
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.service: Succeeded. 2021-06-11T15:56:50Z systemd[1]: Stopped Service for snap application lxd.daemon. 2021-06-11T15:56:55Z systemd[1]: Starting Service for snap application lxd.activate... 2021-06-11T15:56:55Z lxd.activate[7193]: => Starting LXD activation 2021-06-11T15:56:55Z lxd.activate[7193]: ==> Loading snap configuration 2021-06-11T15:56:56Z lxd.activate[7193]: ==> Checking for socket activation support 2021-06-11T15:56:56Z lxd.activate[7193]: ==> Setting LXD socket ownership 2021-06-11T15:56:56Z lxd.activate[7193]: ==> Checking if LXD needs to be activated 2021-06-11T15:56:56Z systemd[1]: snap.lxd.activate.service: Succeeded. 2021-06-11T15:56:56Z systemd[1]: Finished Service for snap application lxd.activate.
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 123B - 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 123B - 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 notice at 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 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
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 and remove snaps. Snaps are packages that work across many different Linux distributions, enabling secure delivery and operation of the latest apps and utilities. OPTIONS COMMANDS abort Abort a pending change The abort command attempts to abort a change that still has pending tasks. Usage: snap abort [abort-OPTIONS]