To answer your questions:
Why are they duplicated?
⇢ They're different revisions (versions), not duplications.
Can I remove the older package to ensure better disk space management?
⇢ Yes. It's your computer, after all.
How do I remove the older package?
You can do this in Terminal like this:
snap remove {snap} --revision={revision}
You can also tell the system how many past versions to limit itself to like this:
sudo snap set system refresh.retain=2
Note: The value must be between 2
and 20
, and a number like 2
or 3
is generally recommended to save storage space and allow a rollback in the event of a bad update.
If you would like to list all the snaps and their versions, you can run this command:
snap list --all
Which will give you something like:
Name Version Rev Tracking Publisher Notes
bare 1.0 5 latest/stable canonical✓ base
canonical-livepatch 10.0.1 119 latest/stable canonical✓ disabled
canonical-livepatch 10.1.2 126 latest/stable canonical✓ -
core 16-2.52 11798 latest/stable canonical✓ core,disabled
core 16-2.52.1 11993 latest/stable canonical✓ core
core18 20211028 2253 latest/stable canonical✓ base
core18 20211015 2246 latest/stable canonical✓ base,disabled
core20 20211115 1242 latest/stable canonical✓ base,disabled
core20 20211129 1270 latest/stable canonical✓ base
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 145 latest/stable canonical✓ disabled
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 161 latest/stable canonical✓ -
gnome-3-34-1804 0+git.3556cb3 77 latest/stable/… canonical✓ -
gnome-3-34-1804 0+git.3556cb3 72 latest/stable/… canonical✓ disabled
gnome-3-38-2004 0+git.cd626d1 87 latest/stable canonical✓ -
gnome-3-38-2004 0+git.6ba6040 76 latest/stable canonical✓ disabled
gtk-common-themes 0.1-52-gb92ac40 1515 latest/stable/… canonical✓ disabled
gtk-common-themes 0.1-59-g7bca6ae 1519 latest/stable/… canonical✓ -
snap-store 3.38.0-66-gbd5b8f7 558 latest/stable/… canonical✓ -
snap-store 3.38.0-64-g23c4c77 547 latest/stable/… canonical✓ disabled
snapd 2.53.2 14066 latest/stable canonical✓ snapd,disabled
snapd 2.53.4 14295 latest/stable canonical✓ snapd
Need a Script?
IMPORTANT: You will want to check the output of snap list --all
on your computer before continuing, and the following is a script that should not be copy/pasted without sanity checking if you are using a locale that is not en_US.UTF-8
.
The Script:
#!/bin/bash
# This script will remove disabled snap revisions.
set -eu
LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read name rev; do
snap remove "$name" --revision="$rev"
done
This will run snap list -all
and extract the lines that contain the word disabled
. This will be different depending on your locale, so check the output of the function first, then update awk '/disabled/
to replace disabled
with the label that is found in your output.
Save the script to a file (for example scrub-snaps.sh
) and then set it as being executable:
sudo chmod +x scrub-snaps.sh
Now you can run it, remembering to use sudo
:
sudo ./scrub-snaps.sh
Note: sudo
was not part of the script, but can be added if you prefer to have it in there. Either way, you'll be prompted for a password if required.