Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Wednesday, July 5, 2023 at 22:17

This tutorial will help you in using Snap Package Manager on your Ubuntu desktop, server and laptop. With Snap, you can install, update, remove and manage software applications as well as games available via Snapcraft.io supported by Canonical the United Kingdom company behind Ubuntu. Now we want to start with the examples included. Enjoy!


  (Nextcloud server and Xonotic shooting game running as Snaps)

Subscribe to UbuntuBuzz Telegram Channel to get article updates.

 

What you can do with Snaps 

 

Snap is a new software package format and way to add/remove programs invented by Canonical for Ubuntu. Since 2018, it is preinstalled on Ubuntu system alongside older software package format/method DEB/APT. More precisely, if you are now using Ubuntu (version 18.04, 20.04, 22.04 and later) or Zorin OS or KDE Neon, then now you have Snap already in your system. For this, we write this article.

Basically, with Snap you can install, update, remove applications and games just like what you can do everyday with DEB. For more information, please read the official website https://snapcraft.io.

To exercise with Snap, read sections number 1 to 8 below. 


1. Reading information

 

First thing to do is to read:

$ snap list --all
$ snap info firefox

First command will show you all installed Snaps on your system. Second one will show you Snap package size and version of firefox. See output examples below. 

In this output, we can observe that our computer running Ubuntu has some 14 Snap packages listed in a table from the first 'bare' to the last 'xonotic'.


We pick one Snap package namely 'firefox' to read its full information as the following. From this output we know information as the following:

  • Program name: Firefox
  • Publisher: Mozilla Foundation
  • Description: web browser
  • License: unset
  • Installed version: 114
  • Installed size: 256MB
  • Revision number: 2800
  • Available versions: 115, 116, 117


 

2. Searching for applications

 

Take three examples below:

$ snap search office
$ snap search server
$ snap search game

From the first command, we observe that both LibreOffice and OnlyOffice are available among the results.


From the second command, we observe Snap packages for server and networking related purposes like RocketChatServer, Nextcloud, Jenkins and several others. Searching further may give us Grafana, Prometheus, OpenStack etc.



3. Installing application

 

Pay attention to these first two commands:

$ snap install obs-studio
$ snap install nextcloud
$ snap run obs-studio
$ snap run nextcloud

The first will install OBS Studio, a desktop application. The second will install Nextcloud, a server application. To run a Snap application, do like the third or fourth command.


4. Updating application

 

Pay attention to these two commands:

$ snap refresh
$ snap refresh firefox

First one will update all installed Snap applications in the system. Second one will just update selected package namely 'firefox'.

 

5. Removing application 

 

To uninstall Snap packages:

$ snap remove nextcloud
$ snap remove nextcloud obs-studio rocketchat-server

First command will remove one package namely 'nextcloud'. Second one will remove multiple packages along with it namely 'obs-studio' and 'rocketchat-server' packages.


6. Installing and removing a version of an application


With Snap, it is possible for publisher to publish an application in multiple different versions and for user to pick a particular version of that application.
$ snap list --all
$ snap remove firefox --revision 1234
$ snap list --all | grep -i firefox

First command will show all Snaps and all revisions installed on your system. Second command will uninstall Snap package name firefox which the revision number is 1234. Use third command to filter 'firefox' out of the result.

 

7. Stop automatic updates

 

Take these two examples:

$ snap refresh --hold
$ snap refresh --unhold

By default, all Snaps update automatically in the background and it is generally a good thing, but this causes issues for Ubuntu users with limited internet access. If you want to disable automatic updates, do the first command. To enable it again, do the second. Either way, without automatic updates you can still update Snap packages manually.


8. Maintain snap services

 

Outside of Snap command, one might need to control Snap services runing in the background.

$ sudo systemctl mask --now snapd
$ sudo systemctl unmask --now snapd

First command will permanently disable and stop snapd (the actual daemon that allows snap to run). Second one will enable and start snapd again. Please note that once disabled, any Snap application or game will not be able to run.


Useful tips and tricks

 

When you don't know what to do:

You can visit Snap documentation website especially the Quickstart Guide section. They have comprehensive guides for new users. See references for the link.


When your disk is full

Use baobab to discover which Snaps take disk space the most -> remove revisions which are not used anymore or noted as "disabled" under Notes column. This can help you manage and remove which ones if you should.


Use info reading (see section 1) to find out disk space used by each of Snap applications.

Note that Snap packages are installed into the directory /var/lib/snapd/snaps. You can compare file size between Snap packages in this directory using baobab.

That's all, happy managing your software with Snap!


**** 

References



This article is licensed under CC BY-SA 3.0.