Linux snap Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux snap command and its practical applications. We will start by introducing the Snap package manager, its key features, and how to check the installed version. Then, we will learn how to install and update Snap packages, as well as manage them using various Snap commands. This lab aims to provide you with a comprehensive understanding of the Snap package management system and its usage on your Ubuntu 22.04 Docker container.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/PackagesandSoftwaresGroup(["`Packages and Softwares`"]) linux(("`Linux`")) -.-> linux/FileandDirectoryManagementGroup(["`File and Directory Management`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/PackagesandSoftwaresGroup -.-> linux/apt("`Package Handling`") linux/FileandDirectoryManagementGroup -.-> linux/find("`File Searching`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") subgraph Lab Skills linux/apt -.-> lab-422925{{"`Linux snap Command with Practical Examples`"}} linux/find -.-> lab-422925{{"`Linux snap Command with Practical Examples`"}} linux/sudo -.-> lab-422925{{"`Linux snap Command with Practical Examples`"}} end

Introduction to Snap Packages

In this step, we will introduce the Snap package manager and explore its key features. Snap is a modern, cross-platform, and secure package management system that allows you to easily install, update, and manage applications on your Linux system.

First, let's check the version of Snap installed on your system:

snap version

Example output:

snap    2.57.4
snapd   2.57.4
series  16
ubuntu  22.04
kernel  5.15.0-1023-aws

As you can see, the Snap version installed on your Ubuntu 22.04 Docker container is 2.57.4.

Snap packages are self-contained applications that include all the necessary dependencies, libraries, and runtime environments. This makes them easy to install, update, and manage, as they are isolated from the underlying system.

To list all the Snap packages currently installed on your system, run the following command:

sudo snap list

Example output:

Name       Version    Rev   Tracking       Publisher   Notes
core20     20220719   1518  latest/stable  canonical✓  core
gnome-3-38-2004  0+git.3036c14  20  latest/stable  canonical✓  -
gtk-common-themes  0.1-36-gc4e3006  1506  latest/stable  canonical✓  -
snap-store 42.3-48-g1b0d8d7  590  latest/stable  canonical✓  classic
snapd      2.57.4     8310  latest/stable  canonical✓  snapd

This command lists all the Snap packages installed on your system, including their names, versions, revisions, tracking channels, publishers, and notes.

Now that you have a basic understanding of Snap packages, let's move on to the next step, where we will learn how to install and update Snap packages.

Installing and Updating Snap Packages

In this step, we will learn how to install and update Snap packages on your Ubuntu 22.04 Docker container.

First, let's install a Snap package. We'll use the popular "vlc" media player as an example:

sudo snap install vlc

Example output:

vlc 3.0.17.3 from 'videolan' installed

This command installs the latest version of the VLC media player as a Snap package.

To update an installed Snap package, you can use the following command:

sudo snap refresh vlc

Example output:

vlc refreshed

This command checks for and installs any available updates for the VLC Snap package.

You can also update all installed Snap packages at once:

sudo snap refresh

Example output:

All snaps up to date.

This command updates all installed Snap packages to their latest versions.

To remove a Snap package, you can use the following command:

sudo snap remove vlc

Example output:

vlc removed

This command uninstalls the VLC Snap package from your system.

Now that you know how to install, update, and remove Snap packages, let's move on to the next step, where we will explore more advanced Snap package management commands.

Managing Snap Packages with Snap Commands

In this final step, we will explore more advanced Snap package management commands to help you effectively manage your Snap packages.

First, let's list all the Snap packages available in the Snap store:

sudo snap find

Example output:

Name                 Version  Publisher   Notes
vlc                  3.0.17.3 videolan    -
gimp                 2.10.30  snapcrafters -
libreoffice          7.3.5.2  libreoffice -
firefox              103.0.2  mozilla     -
code                 1.71.2   microsoft   classic

This command searches the Snap store and lists all the available Snap packages.

You can also search for a specific Snap package by providing a search term:

sudo snap find gimp

Example output:

Name        Version  Publisher   Notes
gimp        2.10.30  snapcrafters -

To get more detailed information about a Snap package, you can use the snap info command:

sudo snap info gimp

Example output:

name:      gimp
summary:   GNU Image Manipulation Program
publisher: snapcrafters
store-url: https://snapcraft.io/gimp
contact:   https://github.com/snapcrafters/gimp/issues
license:   GPL-3.0
description: |
  GIMP is the GNU Image Manipulation Program. It is a freely distributed program for such tasks as photo retouching, image composition and image authoring.

This command provides detailed information about the GIMP Snap package, including its summary, publisher, contact information, license, and description.

Finally, let's explore the Snap package channels. Snap packages can be installed from different channels, such as stable, candidate, beta, and edge. You can use the snap info command to see the available channels for a Snap package:

sudo snap info gimp

Example output:

name:      gimp
summary:   GNU Image Manipulation Program
publisher: snapcrafters
store-url: https://snapcraft.io/gimp
contact:   https://github.com/snapcrafters/gimp/issues
license:   GPL-3.0
channels:
  stable:   2.10.30
  candidate: 2.10.30
  beta:      2.10.30
  edge:      2.10.30

This output shows that the GIMP Snap package is available in the stable, candidate, beta, and edge channels, all with the same version (2.10.30).

You've now learned how to manage Snap packages using various Snap commands. Congratulations on completing this Linux Snap package management lab!

Summary

In this lab, we first introduced the Snap package manager and explored its key features, including its ability to provide self-contained applications with all necessary dependencies. We learned how to check the Snap version installed on the system and list all the Snap packages currently installed.

Next, we covered the process of installing and updating Snap packages. We demonstrated how to install the VLC media player using the Snap package manager, and then discussed the steps to update Snap packages to their latest versions. We also explored the use of Snap commands to manage Snap packages, such as removing, refreshing, and searching for packages.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like