What is Snap Package And How To Manage Them {With Commands}



 Snap Packages

The most popular & trusted universal package manager till date. As it is developed by Canonical, who are the developers of Ubuntu system. It is now preinstalled in  Linux distros including Ubuntu, Manjaro, Zorin etc  and it is also available for most popular  Linux distros in the market. Snaps are self contained applications running in a sandbox with mediated access to the host system.
Let understand the terminology in snap package system.

SnapsThe software packages are called Snaps.
Snapd : These snaps are manage by Snapd which is an daemon service that runs in the background.
SnapStore These snaps are maintained on a central repository called SnapStore .

Snapcraft : A tool which is used to create snap packages is called Snapcraft.
        Snap files are self complete application that means all the dependencies are included with the package. Snap files are comes with .snap extension. You don't need to install the snapstore in order to install the snap packages all you required is snapd & you are ready to install snap packages from terminal. However you can install the snap repository called as snapstore to view and install the application graphically

Installation : To check the snap package manager is install in your system just run the command snap --version from the terminal window. And to check the snapd service is running in the background run command systemctl status snapd . You will see the output as below. However it is include in Manjaro, Ubuntu, KDE Neon, Solus3 & ZorinOS latest distributions.

If somehow your system has no snapd services installed , you can install it for your system. Snap is supported by all major Linux distros. just try to install with native package manager command.
For Ubuntu it is as below :

sudo apt-get update && sudo apt-get install snapd
For Redhat / CentOS :
sudo yum install epel-release #enable CentOS repo
sudo yum install snapd #install snapd
sudo systemctl enable --now snapd.socket # enable services

For Arch/Manjaro OS:
sudo pacman -S snapd
Or for more information visit the official documentation page

Installatin Options :

After installing the snapd package for your system , you are ready to install any package which is available in snapd store. 
A syntax is given below with an example to install a snap package :

sudo snap install 'PACKAGE_NAME'

The example below is an installation of VS code editor for Linux using snap.
 sudo snap install --stable vlc

To get information about a package run below command
 snap info vlc
To install a specific version of a package (e.g  stable, beta, candidate, edge)

sudo snap install channel=stable  vlc


sudo snap install --stable vlc

To remove a package from system
sudo snap remove 'PACKAGE_NAME'


Updates Options
By default snap packages update automatically & check updates 4 times in a day but still you can manually update the packages in snap.

- To update all installed snap packages

$ snap refresh
gnome-system-monitor 3.28.2 from 'canonical' refreshed
gnome-calculator 3.28.2 from 'canonical' refreshed

- To check last update time

$ snap refresh --time

- To check which application will be updated in next refresh, run below command.

snap refresh --list

Controlling Updates

You can control how frequently your snap packages will update. You can schedule your updates withe help of below commands.

refresh.times : This option helps you to schedule your snap packages for updates in a specific time. see the below command example.

sudo snap set system refresh.timer=7:00-9:00,22:00-23:59 

The above command will set a schedule your snaps to update at 07:00 to 09:00 a.m and 10:00 to 23:59 pm.

- To stop auto update till a specific date use below commands steps.

i) Generate the specific time which you want to use to hold your update till that date. For this first you have to check the current time and its format.

$ date


Above command will confirm you about the current time and date format and time zone. Now generate the date and time which you will use to hold your snap updates with below commands.

$ date --date="IST 2020-09-20 18:30:00" "+%Y-%m-%d %H:%M:%S"

In above example I choose 20 September 2020 , 6:30 p.m to hold snap update for my system. So my . Now run the final commands to tell the system do not update snap packages till that time.

sudo snap set system refresh.hold="$(date --date="IST 2020-09-20 18:30:00" "+%Y-%m-%dT%H:%M:%S%:z")"

Use snap refresh --time to verify it.

- To hold updates for metered connection.

sudo snap set system refresh.metered=hold 

- To re-enable the updates on metered connection

sudo snap set system refresh.metered=null

Monitoring Options

To check previous actions either you install , remove , update a package ,  run below command to check.

snap changes

To get more details about any action use ID number.

snap change 8

Connections Options : 

A snap application is connected via an interface to communicate with the outside system resources. Snaps are designed for strong application isolation and safe interface connections are made automatically. So you dont need to worry about interface too much however you can check which interface is currently using in a snap application.

- To see which interfaces a snap is using, and which interfaces it could use but isn’t,  use below command

snap connections snap_name

Note: If slot have null value then an interface is not connected else connected with snap app.

- To see which other snaps are using an interface with the interface command:

snap interface camera

Configuration Options :

You can see or modify a configuration of a snap package using below command.

- To see the configuration options exposed by an installed snap.

sudo snap get snap_name


Key                Value

mode             production

Snap_name        {...} 

php              {...} 

ports            {...}

private          {...}

To explore configuration options, append the key name to the get command:

sudo snap get snap_name ports


Key            Value

rts.http     80 

ports.https    443

So these are some important commands in of snap package manager in Linux. There are more advance commands to manage & modify snap applications functionality according to your choice. 

Please share the post with your friends that will encourge us to make some more useful post  😀


Post a Comment