Archives For snap

Ubuntu finally added support for disabling automatic updates for snap applications, though it’s currently considered experimental at the moment of writing.

As you may know, Snap is an universal package format runs in sandbox. It’s developed by Canonical, the company behind Ubuntu, as a competitor to Flatpak.

The pre-installed Firefox in Ubuntu 22.04+, and Ubuntu Software in Ubuntu 20.04+ are Snap applications. And there are lots of apps in Ubuntu Software available as Snap, including Chromium browser, Skype, and more.

By default, Snap apps automatically update to the newest version. Though, user can delay or specify when to perform updates. It was impossible to completely disable automatic updates due to security issue.

But as the snap update mechanism has been continuously refined, and to give IT teams more control they expect for Linux systems, this long-awaited feature is finally released for preview.

Hold or completely disable Snap updates

The function is done via a new --hold parameter using snap refresh command.

  • For example, completely disable automatic updates for Firefox via command:
    snap refresh --hold firefox
  • Or, hold automatic updates for 24 hours for both firefox and snap-store via command:
    snap refresh --hold=24h firefox snap-store
  • For all the Snap apps, just skip package name in the command. So, disable automatic updates for all apps by running command:
    snap refresh --hold

Oppositely, re-enable automatically updates via --unhold parameter.

  • To re-enable updates for all apps, use command:
    snap refresh --unhold
  • To re-enable center apps, such as Firefox, use command:
    snap refresh --unhold firefox

Switch Snapd to edge channel

As mentioned, the feature is not in edge channel for preview. If you found the commands above do not work, but you really want to try it out, switch Snapd daemon to edge channel via command:

snap refresh snapd --edge

And verify by running snap list |grep snapd command.

To switch back the daemon package to stable channel, use command:

snap refresh snapd --stable

via: this post.

How to Delay or Tell When to Update Snap Apps in Ubuntu

Ubuntu automatically checks and updates all installed Snap packages 4 times every day. Here’s how you can delay or assign a certain time period for the automatic update.

Snap is an Ubuntu developed universal package format that runs in sandbox. Few core apps (such as Ubuntu Software and Firefox in 22.04) and many software in Ubuntu Software are Snap packages. Unlike classic .deb package, snap updates all the packages automatically in the background silently without user intervention.

If you didn’t block the Snap package, you must have some installed on your Ubuntu machine. And, to avoid conflict to daily work (e.g., online meetings, data backup), you may tell Snap when to do the updates.

Check when Snap will do updates:

By default, snap check (and install if any) updates 4 times per day. You may verify it by pressing Ctrl+Alt+T on keyboard to open terminal and run command:

snap refresh --time

Besides the time period and frequency, it also tells when the last done and next will occur.

Hold or Completely Disable Automatic Updates

The developer team finally added the --hold parameter, so user can hold updates for either certain app or all snaps for given time or indefinitely.

NOTE: the commands below work only for edge channel of snapd daemon at the moment of writing.

Simply open terminal and run command, and run command to hold updates for 24 hours via command:

snap refresh --hold=24h firefox

Or completely disable automatic updates for firefox via:

snap refresh --hold firefox

To disable automatic updates for all snap applications, run command:

snap refresh --hold

To re-enable automatic updates, use command to unhold all:

snap refresh --unhold

Or unhold specified app via command:

pre>snap refresh –unhold firefox

Specify time period for Snap update

To tell when and how often to check updates, it can be done by running a single command in terminal to set the value of “refresh.timer”.

For example, to allow only between 4.00am and 6.00am, and 9.00pm and 12.00pm, use command:

sudo snap set system refresh.timer=4:00-6:00,21:00-24:00

Or, only check/install updates twice in weekend via command:

sudo snap set system refresh.timer=sat,sun,0:00-24:00/2

Other examples include between 10.00pm and 11.00pm from Monday to Wednesday, and between 9.00am and 11.00am on Friday.

sudo snap set system refresh.timer=mon-wed,22:00-23:00,,fri,9:00-11:00

Or second Monday of the month between 9:00 and 11:00 via command:

sudo snap set system refresh.timer=mon2,9:00-11:00

Delay the update

Ubuntu supports to delay snap updates by specifying a value to “refresh.hold” up to 90 days.

1. Firstly, in case you don’t know your time zone short name, run command:

date

It will output the current date and time, as well as time zone (e.g., NST, AST, EST, PST, CST).

2. Next, use the command below to convert your desired time (e.g., July 7, 2022) to the right format:

date --date="CST 2022-07-07 18:22:00" +%Y-%m-%dT%H:%M:%S%:z

Replace the time zone, date and time in bold. And, copy the output time for use in next command.

3. Finally, delay snap refresh until the given date and time.

sudo snap set system refresh.hold=2022-07-07T18:22:00+08:00

To verify the change, use command:

sudo snap get system refresh.hold

Prevent update when on metered connections

If you’re running Ubuntu on a metered network connection. Which mean you have limited amount of data per month or day. You can prevent Snap from doing updates by running command:

sudo snap set system refresh.metered=hold

To undo this change, use command:

sudo snap set system refresh.metered=null

Ubuntu is distributing more applications as the universal Snap package, but some users don’t like them. So I’m writing this tutorial for those want to completely get rid of Snap and prevent it from being installed back.

NOTE: Before getting started, please backup your app data, e.g., Firefox bookmarks. Attention that Ubuntu Software will also be removed after following this tutorial.

Step 1. Remove Snap apps and the Daemon

Press Ctrl+Alt+T on keyboard to open a terminal window. When it opens, run the commands below one by one.

1.) List all installed snap applications:

snap list

They are by default Snap Store (Ubuntu Software), Firefox, default theme, and few core packages.

2.) Remove the apps one by one, Firefox and Snap-store go first, then theme package, gnome platform (in sandbox), and finally base packages and snapd daemon. NOTE: the package names may vary depends on “snap list” output.

sudo snap remove --purge firefox
sudo snap remove --purge snap-store
sudo snap remove --purge gnome-3-38-2004

Also run snap remove command to remove “gtk-common-themes”, “snapd-desktop-integration”, “bare”, “core20”, and finally “snapd”.

3.) Finally remove the Snap daemon package via apt:

sudo apt remove --autoremove snapd

Step 2. Block Snap package

After completely removed snap packages, you may prevent Ubuntu from installing them back by settings low priority for the Snapd package. Here’s how to do the trick inspired by the way Linux Mint 20 did.

1.) Press Ctrl+Alt+T on keyboard to open terminal. When it opens, run the command below to create and open a configuration file:

sudo gedit /etc/apt/preferences.d/nosnap.pref

When the file opens, paste lines below to tell refuse snapd from any repository:

# To prevent repository packages from triggering the installation of snap,
# this file forbids snapd from being installed by APT.

Package: snapd
Pin: release a=*
Pin-Priority: -10

2. After save the file, refresh package cache via command:

sudo apt update

Now, whenever you try to installed a Snap package or the daemon, it outputs either unmet dependencies (snapd) or package has no installation candidate.

How to Restore:

If you change your mind, run the commands below at any time will install back the Snap apps.

Firstly, run command in terminal (Ctrl+Alt+T) to unblock the daemon:

sudo rm /etc/apt/preferences.d/nosnap.pref

Then, install Ubuntu Software via command:

sudo snap install snap-store

And install Firefox as snap if you want by running command:

sudo apt install firefox

This simple tutorial shows how to search for, install, remove, and list installed Snap applications in Ubuntu from command line.

Snap is an universal Linux package format developed by Canonical, the company behind Ubuntu. Though many users hate the Snap apps, it’s hard to keep away from it since many popular applications (e.g., VLC, Spotify, VS Code, Android Studio) offer official Ubuntu binaries through Snap rather than classic deb package.

As Ubuntu Software still sucks and does not load application pages quite often, you can run followings command instead to search for & install snap applications.

1. Searching for Snap Apps in Terminal:

Simply open terminal from system application launcher. You can then either run snap find or snap search command follow with app name to query the store for available packages.

Both commands below do the same searching for GIMP packages:

snap find gimp

snap search gimp

For the verified publisher, you’ll see a green check mark after the publisher name.

2. Command to Install a Snap App:

To install a Snap application package, simply run snap install command follow with the package name.

After searching for an app, you can then select install one from available packages by running command (VLC for instance):

snap install vlc

Some applications support for installing with --classic flag to access files outside user’s home directory. So, the command could be:

snap install vlc --classic

Usually, we install Snap applications from the stable channel. There are also beta, edge, candidate channels include packages for testing purpose. For example, install VLC from its Beta channel, use command:

snap install vlc --channel beta

3. How to List installed Snap applications:

To list all installed snap applications, simply run snap list in terminal.

snap list

While “core” and “core18” are snap core packages, “snap-store”, “snap-store-proxy”, and “snap-store-proxy-client” relates to the Ubuntu Software.
All others are user installed packages, though “gnome-3-xxx” packages were installed automatically as dependency platform.

Snap apps update automatically when new release packages published. So, there may be old packages present in your system after using them for a period of time. To list all of them, use command:

snap list --all

Old packages should be marked as ‘disabled’.

4. How to Remove Snap Apps via command:

To remove a snap package, simply run snap remove command follow with package name.

In the case, I’m going to remove VLC snap package via command:

snap remove vlc

NOTE that the dependency platform (e.g., gnome and wine) won’t to be removed while removing the snap that requires it.

The previous remove command will leave a snapshot of app data on your system. Use --purge flag will clear all the app data:

snap remove --purge vlc

Thanks to @Fernando, the command below will free up disk space by removing all the old disabled snap packages:

snap list --all | awk '/disabled/{system("sudo snap remove " $1 " --revision=" $3)}'

Summary:

In brief you can run snap find APP_NAME or snap search APP_NAME to search for available packages. Use snap install PACKAGE_NAME or snap remove PACKAGE_NAME to install or remove an application. And run snap list to list all installed snap applications.

Install OBS Studio Easily via Snap in Ubuntu

Last updated: June 25, 2018

For those who don’t want to add third-party repositories, the free and open-source streaming and recording program OBS Studio now can be easily installed in Ubuntu via Snap package.

Snap is an universal Linux package format. Snap application runs in sandbox and it auto-updates itself once a new release is out and snapped by the maintainer.

The latest OBS Studio 21.1.2 is now available as snap package. You can easily install it from Ubuntu Software:

For Ubuntu 16.04 users who never installed a snap package, run command sudo apt install snapd first to install the daemon.

Or run command in terminal (Ctrl+Alt+T) to install the OSB Studio snap package:

snap install obs-studio

You may found that the snap package is kinda large in file size that because it bundles almost all its dependencies.

NOTE: To access webcam and content on external storage, you need to run 2 two commands:

sudo snap connect obs-studio:camera

sudo snap connect obs-studio:removable-media

Finally launch the software from Gnome launcher or Unity launcher (may need to log out and log in back) and enjoy!