141

I know that I can update a snap package using

sudo snap refresh <package>

But is there a way to update all snaps, like

sudo apt dist-upgrade
212
snap refresh 

will do this. It is part of snapd 2.0.8, which landed 2016-06-13 in xenial-updates.

snap refresh --list

only lists the updates without refreshing the packages.

snap info <snap name>

can show which versions are available for a particular package.

  • 17
    snap refresh --list only lists the updates without refreshes the packages – gwarah Jan 4 '18 at 14:15
  • 1
    You need to do sudo snap refresh – Boris Apr 25 '19 at 4:03
  • 3
    @Boris, snap prompts you for your password if you don't include sudo so it's not entirely necessary. – SpookyGengar Nov 7 '19 at 22:53
  • 1
    @SpookyGengar no it doesn't: $ snap refresh error: access denied (try with sudo) – Ricky Nelson Nov 26 '19 at 21:29
  • @RickyNelson On my 18.04 it does prompt me without using sudo – John Jan 10 at 2:18
29

According to Snap tutorial Snaps are automatically updated in the background once per day.

  • However, I was checking Firefox today which said "Updates disabled by your system administrator" (strange since I am the only user and I just installed my OS three days ago). snap refresh firefox was the only way to get the latest security patches. – John Jan 10 at 2:20
  • Interesting. Please add a comment if you ever find out why that's the case... – chrisvdb Jan 10 at 3:11
4

Try this in /usr/bin/update-snaps:

#!/bin/bash
ROOT_UID="0"

#Check if run as root
if [ "$UID" -ne "$ROOT_UID" ] ; then
        echo "You must be root to do that!"
        exit 1
fi

snap list | awk -F" " '{if ($1 && NR>1) { system("snap refresh " $1 " 2>/dev/null") }}'
  • 4
    This is not necessary any more. – dholbach Jun 14 '16 at 7:11
  • Why not? auto-updates, right? – ambigus9 Jun 26 '19 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.