Cyberithub

How to Install Snap on Ubuntu 22.04

Advertisements

In this article, we will see how to install snap on Ubuntu 22.04. Snap is a free and open source command line utility to install app packages(also known as snaps) on linux based systems. Snaps are containerized app packages with all its dependencies bundled together so that it does not require any external packages for installation. To manage and maintain snaps, a background daemon service called snapd needs to be installed and running. Without this service, a snap cannot be installed. Since snap utility comes with snapd package so instead of installing just snap utility, we will install snapd package on Ubuntu 22.04 using steps mentioned in below section.

 

How to Install Snap on Ubuntu 22.04

How to Install Snap on Ubuntu 22.04

Also Read: [Solved] "Failed to restart snapd.mounts-pre.target: Operation refused"

Step 1: Prerequisites

a) You should have a running Ubuntu 22.04 Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility available in your Server.

 

Step 2: Update Your Server

Before installing snapd package, it is recommended to check for any latest available updates and install them using sudo apt update && sudo apt upgrade command as shown below.

cyberithub@ubuntu:~$ sudo apt update && sudo apt upgrade
[sudo] password for cyberithub:
Hit:1 https://artifacts.elastic.co/packages/8.x/apt stable InRelease
Hit:2 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:5 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:6 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:7 https://ngrok-agent.s3.amazonaws.com buster InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
libjq1 libonig5
Use 'sudo apt autoremove' to remove them.
The following packages have been kept back:
alsa-ucm-conf grub-efi-amd64-bin grub-efi-amd64-signed
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

 

Step 3: Install Snap

In the next step, you can install snap utility by using sudo apt install snapd command as shown below. This will download and install the package from default Ubuntu repo along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
snapd
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 23.8 MB of archives.
After this operation, 102 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 snapd amd64 2.58+22.04.1 [23.8 MB]
Fetched 23.8 MB in 16s (1,491 kB/s)
(Reading database ... 234348 files and directories currently installed.)
Preparing to unpack .../snapd_2.58+22.04.1_amd64.deb ...
Unpacking snapd (2.58+22.04.1) ...
Setting up snapd (2.58+22.04.1) ...
snapd.failure.service is a disabled or a static unit, not starting it.
snapd.mounts-pre.target is a disabled or a static unit, not starting it.
snapd.mounts.target is a disabled or a static unit, not starting it.
snapd.snap-repair.service is a disabled or a static unit, not starting it.
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for dbus (1.12.20-2ubuntu4.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...

 

Step 4: Verify Installation

After successful installation, you can verify the installed files path by using dpkg -L snapd command as shown below.

cyberithub@ubuntu:~$ dpkg -L snapd
/.
/etc
/etc/apparmor.d
/etc/apparmor.d/usr.lib.snapd.snap-confine.real
/etc/apt
/etc/apt/apt.conf.d
/etc/apt/apt.conf.d/20snapd.conf
/etc/profile.d
/etc/profile.d/apps-bin-path.sh
/etc/xdg
/etc/xdg/autostart
/etc/xdg/autostart/snap-userd-autostart.desktop
/lib
/lib/systemd
/lib/systemd/system
/lib/systemd/system/snapd.aa-prompt-listener.service
/lib/systemd/system/snapd.apparmor.service
/lib/systemd/system/snapd.autoimport.service
/lib/systemd/system/snapd.core-fixup.service
/lib/systemd/system/snapd.failure.service
/lib/systemd/system/snapd.mounts-pre.target
..............................................

 

Step 5: Check Version

You can also check the current installed version by using snap --version command as shown below.

cyberithub@ubuntu:~$ snap --version
snap   2.60.3
snapd  2.60.3
series 16
ubuntu 22.04
kernel 6.2.0-32-generic

 

Step 6: Verify Service Status

To verify snapd daemon status, run systemctl status snapd command. You should see the services as active and running on the output as shown below. You can also start or restart the service by running sudo systemctl start snapd or sudo systemctl restart snapd command.

cyberithub@ubuntu:~$ systemctl status snapd
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-10-03 23:36:51 IST; 28s ago
TriggeredBy: ● snapd.socket
   Main PID: 68839 (snapd)
      Tasks: 10 (limit: 4542)
     Memory: 104.3M
        CPU: 11.513s
     CGroup: /system.slice/snapd.service
             └─68839 /usr/lib/snapd/snapd

Oct 03 23:36:40 ubuntu systemd[1]: Starting Snap Daemon...
Oct 03 23:36:41 ubuntu snapd[68839]: overlord.go:272: Acquiring state lock file
Oct 03 23:36:41 ubuntu snapd[68839]: overlord.go:277: Acquired state lock file
Oct 03 23:36:41 ubuntu snapd[68839]: patch.go:64: Patching system state level 6 to sublevel 1...
Oct 03 23:36:41 ubuntu snapd[68839]: patch.go:64: Patching system state level 6 to sublevel 2...
Oct 03 23:36:41 ubuntu snapd[68839]: patch.go:64: Patching system state level 6 to sublevel 3...
Oct 03 23:36:41 ubuntu snapd[68839]: daemon.go:247: started snapd/2.60.3 (series 16; classic) ubuntu/22.04 (amd64) linux/6.2.0-32-generic.
Oct 03 23:36:42 ubuntu snapd[68839]: daemon.go:340: adjusting startup timeout by 1m45s (pessimistic estimate of 30s plus 5s per snap)
Oct 03 23:36:42 ubuntu snapd[68839]: backends.go:58: AppArmor status: apparmor is enabled and all features are available (using snapd provided apparmor_pars>
Oct 03 23:36:51 ubuntu systemd[1]: Started Snap Daemon.

 

Step 7: Using Snap

Now that snap utility is installed and available to use, let's install a sample snap package called jq using sudo snap install jq command as shown below.

cyberithub@ubuntu:~$ sudo snap install jq
jq 1.5+dfsg-1 from Michael Vogt (mvo*) installed

To remove the package, you can use sudo snap remove jq command as shown below.

cyberithub@ubuntu:~$ sudo snap remove jq
jq removed

To check all the information about jq snap package, run snap info jq command as shown below.

cyberithub@ubuntu:~$ snap info jq
name: jq
summary: The jq command
publisher: Michael Vogt (mvo*)
store-url: https://snapcraft.io/jq
contact: snaps@canonical.com
license: Other Open Source
description: |
  The jq command
snap-id: 8X4ytHZ2xX4kNkr8V2NU3AQuoMlglwED
channels:
  latest/stable: 1.5+dfsg-1 2017-05-17 (6) 245kB -
  latest/candidate: 1.5+dfsg-1 2017-05-17 (6) 245kB -
  latest/beta: 1.6 2018-11-19 (11) 1MB -
  latest/edge: 1.6 2022-07-14 (19) 1MB -

 

Step 8: Uninstall Snap

If you are planning to remove snapd package from your system then I would suggest instead of running sudo apt remove snapd command, run sudo apt purge snapd --auto-remove command. It is simply because this command won't just remove the package but also all the configuration files related to the package along with all its dependencies.

cyberithub@ubuntu:~$ sudo apt purge snapd --auto-remove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
snapd*
0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
After this operation, 102 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 234444 files and directories currently installed.)
Removing snapd (2.58+22.04.1) ...
Warning: Stopping snapd.service, but it can still be activated by:
snapd.socket
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for dbus (1.12.20-2ubuntu4.1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
(Reading database ... 234351 files and directories currently installed.)
Purging configuration files for snapd (2.58+22.04.1) ...
Stopping snap-bare-5.mount
Stopping unit snap-bare-5.mount

Leave a Comment