How to work with snap packages on Linux

If you have Linux software packages with. to install snap , you can say goodbye to dependency hell and breaking other working applications. Snap packages were originally developed for Ubuntu , but are now available on a variety of Linux distributions.

What are snap packages?

In the past, installing applications on Linux has been a potentially frustrating experience. You would only install something to find a particular library or other dependency that is missing or out of date. You would then find and install the missing resource only to find a different application depending on the version of the library you just replaced. Fix one, break one, repeat.

This has been improved with better package management systems, such as: suitable , dnf , and pacman . However, you still face problems when you need to install different versions of the same application. Or when you have two applications that collide because they are tied to specific – but different – versions of a library.

One solution to these problems is application packaging and delivery systems. Snappy is one of the most popular of these. It is based on a packaging and delivery system called Click, which is based on the Ubuntu touch Initiative. AppImage and Flat pack are others you might have met.

These systems encapsulate the application along with all dependencies and other requirements in a single compressed file. The application then runs in a kind of mini-container. It’s sandboxed and separate from other applications. The libraries and other resources with which the application is packaged or required are available only to it.

They are not installed in the traditional sense, so they do not cause problems with other applications that require different versions of the same resources. You can even install and run applications that require conflicting library versions because each application is in its own sandbox.

However, if they are not installed as usual, how are they treated? Well, the single package file will be downloaded, decompressed, and saved as a SquashFS virtual file system . It is then presented to you as a virtual environment. All of this takes place behind the scenes. All they know is that you’ve installed an application and can now access it.

Of course, since each package file must contain all of the resources that the application needs, the package files can be large. It’s also easy to duplicate a resource that you would normally only install once, such as: MySQL or Apache . If two different snap Applications require the same resources, everyone brings their own copy.

However, this is the tradeoff for ease of installation and the elimination of the resource conflict headache.

Install snapd

Snappy was introduced with Ubuntu 16.04. So if you’re using this version or higher, you’re good to go. On our machine, Snappy was installed on Manjaro 18.04, but we had to install it on Fedora 31.

snap is both the name of the package files and the command you use to interact with them. Behind the scenes, the snapd daemon is also the name of the package to install if you don’t already have Snappy on your computer.

To install snapd At Fedora enter the following command:

                      sudo dnf install snapd

If you need to install it on Manjaro use these commands:

                      sudo pacman -Sy snapd
                      sudo systemctl enable --now snapd.socket

You can use the … snap version Command to see the version of the snap Client, snapd Daemon and the serial number of the software. The name and release of your Linux distribution and the kernel version are also displayed.

Enter the following:

                      snap version

Install Snap Packages

It’s a pretty straightforward process, a. to install snap Package. You can use snap Looking for snap Packages, and then install the one you want.

We enter the following to find and install the Gimp image editor :

                      snap find gimp

snap searches for matches with the search term “gimp” and returns its results. It finds everything that matches or mentions the search term.

To install one of the packages, we use the value from the Name Column as shown below:

                      sudo snap install gimp

During the download, the percentage of completed count increases and a progress bar creeps over from the left side of the terminal window. When the installation is complete, you will see a message (as shown below) letting you know that the package has been installed.

You can use the … df Command to Check the capacity and usage of the various file systems configured on your Linux computer. If we put its output in the grep Command and search for “gimp”, we isolate the entry for the package we just installed.

We enter the following:

                      df | grep gimp

This shows us that the snap package was mounted as if it were a filesystem. The mount point is in the snap Directory here: /snap/gimp/252 . The “252” is the release number of this version of gimp .

How to use the grep command on Linux

The file system is listed as: /dev/loop18 . Loop device files are used to make regular files accessible as block devices. They are typically used to mount the file systems in disk images. In this case they mount the SquashFS File system within the snap Package. The “18” means that this is the 18th /dev/loop Device file used on this Linux computer.

We can use that df Command to check this quickly. We use the – t (Type) Option to limit the output to SquashFS file types only.

We enter the following:

                      df -t squashfs

The assembled SquashFS File systems listed. A /dev/loop Device file handles everyone, and there are 18 of them.

Each file system is stored in a directory within the /snap Directory. However, that doesn’t mean there are 18 different ones snap Packages installed on this computer. This is an Ubuntu distribution, so some snap Packages install right out of the box, and we just installed another one.

Besides, when you install snapd , it installed some cores snap Packages to meet the needs of others snap Packages.

We can use that snap list Command as shown below to get the installed snap Packages:

                      snap list

The output was a bit wide so the end of the listings is shown below.

Here is the full listing:

                      Name                 Version                    Rev   Tracking  Publisher    Notes
core                 16-2.43.3                  8689  stable    canonical*   core
core18               20200124                   1668  stable    canonical*   base
gimp                 2.10.18                    252   stable    snapcrafters -
gnome-3-26-1604            98    stable/...  canonical*   -
gnome-3-28-1804      3.28.0-16-g27c9498.27c9498 116   stable    canonical*   -
gnome-calculator     3.34.1+git1.d34dc842       544   stable/...  canonical*   -
gnome-characters     v3.32.1+git3.b9120df       399   stable/...  canonical*   -
gnome-logs           3.34.0                     81    stable/...  canonical*   -
gnome-system-monitor 3.32.1-3-g0ea89b4922       127   stable/...  canonical*   -
gtk-common-themes    0.1-28-g1503258            1440  stable/...  canonical*   -

As you can see, there are 10 Snap packages installed, not 18. However, those 10 packages have to be 18. guided SquashFS File systems. The table columns are pretty self-explanatory, but here are some explanations:

  • Surname : The name of snap Package that was installed.
  • execution : The version number of the software in snap Package.
  • Rev : The revision number of the snap Package.
  • persecution : The channel this snap Package monitors for updates. There are four:
    • Stable: The standard channel. As the name suggests, this channel contains the most stable packets.
    • Candidate: This channel is less stable, but very close because it contains release candidate level software that is code complete. It goes through final tests before being moved to the stable channel.
    • Beta: This channel has late cycle quality but cannot be guaranteed to be stable.
    • Edge: For early build testers. You should not use this channel for important work or on a production computer. There are dragons here!
  • editor : The person, company, or organization that runs the snap Package. If it’s a verified publisher (and your terminal window supports Unicode ) a green check mark appears next to the publisher’s name. If the check mark can’t appear, you’ll see an asterisk ( * ).
  • Remarks : Any comments or additional information will be displayed here.

The snap channels

You can use the … info Option to include a description of a. to obtain snap Package.

To do this, we enter the following:

                      snap info gtk-common-themes

We can see which channel the package is tracking and the version of the software in the snap Packets in each of the four channels. For the most part, you should stick to the stable channel.

A snap The package checks four times a day to see if a newer version of the software is available on the channel it is watching or “tracking”. If you want to change the channel a snap You can use the refresh and --channel Options.

To do this, we enter the following:

                      sudo snap refresh gtk-common-themes --channel=beta

If a newer version of the software was available it would be installed, but this was not the case. However, it is snap Package is now tracking the beta Channel. As soon as a new one beta Version is published, it will be automatically downloaded and updated.

You can use the … --list Option to check for updates for any of the snap Packages installed on your computer.

To do this, we enter the following:

                      sudo snap refresh --list

You will be informed when one of the channels the snap Packages on your computer that are being tracked contain newer versions of the software.

If a newer version of the software is available, you can download the refresh Option as shown below to manually force an update:

                      sudo snap refresh gtk-common-themes

Remove a snap package

How to uninstall a snap Package you can use the removal option as shown below:

                      sudo snap remove gimp

The snap cheat sheet

Using Snap packages is pretty straightforward, but we’ve compiled a list of a few commands to help you:

  • To find a package: snap find package_name
  • To install a package: sudo snap install package_name
  • To view all installed packages: snap list
  • To get information about a single package: snap info package_name
  • To change the channel a package tracks for updates: sudo snap refresh package_name --channel=channel_name
  • To see if updates are ready for installed packages: sudo snap refresh --list
  • To update a package manually: sudo snap refresh package_name
  • To uninstall a package: sudo snap remove package_name
Linux commands
Files tar · pv · cat · tac · chmod · grep · difference · sed · With · man · pushed · popd · fsck · Test disk · seq · fd · pandoc · CD · $ PATH · awk · join · jq · wrinkles · unique · journalctl · tail · stat · ls · fstab · echo · fewer · chgrp · chown · Rev · look · Strings · Type · rename · Postal code · unzip · assemble · ummount · To install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · weather · Nano · mkdir · from · ln · Patch · Convert · rclon · Scraps · srm
Processes alias · screen · above · kind · renice · progress · strace · system · tmux · chsh · story · at · Batch · for free · which · dmesg · chfn · User mod · ps · chroot · xargs · tty · pinkie finger · lsof · vmstat · Time out · Wall · Yes sir · kill · sleep · sudo · it is · Time · groupadd · User mod · groups · lshw · switch off · start anew · Stop · switch off · passwd · lscpu · crontab · date · bg · fg
Networking netstat · Ring · Trace route · ip · ss · who is · fail2ban · bmon · she · finger · nmap · ftp · curl · wget · who · who am I · w · iptables · ssh-keygen · ufw

Best Linux Laptops for Developers and Enthusiasts

Related Posts