Ubuntu 26.04 Tutorial / Manage Snap Installation, Permissions, and Updates

Manage Ubuntu Server Snaps from the command line by checking installed revisions, publishers, channels, interfaces, and refresh state. Snaps are separate from APT Deb packages, so distinguish execution paths, formats, and data locations even for matching program names.

Identify packaging and publisher

Read publisher, description, and channels with snap info APP_NAME and compare installed name, version, and tracking channel with snap list. Use command -v COMMAND to identify its executable. Matching names do not establish identical maintainers, update paths, or configuration locations.

Ubuntu Server’s package-management guide covers APT and Snap installation and management.

snap list
snap changes
snap refresh --time

Record actual names, versions, and tracked channels from snap list. snap changes shows operations such as installations and refreshes. No APT updates does not establish that every Snap is current.

Install and run a small practice app

snap info hello-world
sudo snap install hello-world
hello-world

Check whether hello-world was already installed; preserve an existing installation and channel. Review its publisher before installation, then verify execution. If the command is not on PATH, inspect the login session and /snap/bin rather than installing duplicates.

Understand channels and confinement

Channels can specify a track, risk level, and branch. Stable, candidate, beta, and edge represent different release streams; do not treat them as equally suitable. Prefer the publisher’s recommended stable stream and record the existing channel and data backup before switching.

Strict, classic, and devmode have different confinement conditions. Understand why an app requires classic access. Do not append --classic or --devmode simply to suppress an installation failure.

Inspect interfaces and access failures

Choose an installed name from snap list and inspect snap connections app-name. External-storage failures can involve both interfaces and filesystem mounts or permissions. Do not connect every interface indiscriminately.

Identify the required interface with snap info APP_NAME, snap connections APP_NAME, and publisher documentation, grant only that access, and test it. Record the original state so you can disconnect only the newly added interface. Interface connections do not replace host filesystem permissions.

Inspect declared interfaces and restore only a new connection

For an installed server Snap, identify a required interface from publisher documentation. Compare Plug/Slot in snap connections APP_NAME with snap interface INTERFACE_NAME. Pass the exact observed SNAP:PLUG and SLOT to this script. An absent declared plug is a reason to stop, not to invent a permission.

Save the complete script as ~/test-snap-interface.sh and run bash ~/test-snap-interface.sh ACTUAL_SNAP:PLUG ACTUAL_SLOT. Existing connections remain intact. Test only the documented feature in another terminal, then press Enter to undo the new connection. Do not grant sensitive system interfaces merely for practice on a production server.

set -eu
if [ "$#" -ne 2 ]; then
    printf 'Usage: bash test-snap-interface.sh SNAP:PLUG SLOT\n' >&2; exit 2
fi
plug=$1
slot=$2
app=${plug%%:*}
case "$plug" in *:*) ;; *) printf 'Use the exact Plug from snap connections.\n' >&2; exit 2 ;; esac
case "$slot" in *:*) ;; *) printf 'Use the exact Slot from snap connections.\n' >&2; exit 2 ;; esac
snap list "$app"
connections=$(LC_ALL=C snap connections "$app")
printf '%s\n' "$connections"
previous_slot=$(printf '%s\n' "$connections" | awk -v p="$plug" '$2 == p {print $3}')
case "$previous_slot" in
    -) ;;
    '') printf 'Declared plug not found; stop.\n' >&2; exit 1 ;;
    *) printf 'Already connected to %s; preserve it.\n' "$previous_slot"; exit 0 ;;
esac
restore() {
    original_status=$?
    trap - EXIT HUP INT TERM
    if ! connections=$(LC_ALL=C snap connections "$app"); then
        printf 'Cannot inspect the connection; verify restoration manually.\n' >&2; exit 1
    fi
    current_slot=$(printf '%s\n' "$connections" | awk -v p="$plug" '$2 == p {print $3}')
    case "$current_slot" in
        "$previous_slot") ;;
        "$slot")
            if ! sudo snap disconnect "$plug" "$slot"; then
                printf 'Restoration failed; inspect the connection.\n' >&2; exit 1
            fi
            ;;
        *) printf 'Unexpected connection state; inspect before disconnecting.\n' >&2; exit 1 ;;
    esac
    if ! connections=$(LC_ALL=C snap connections "$app"); then
        printf 'Cannot verify restoration; inspect the connection.\n' >&2; exit 1
    fi
    printf '%s\n' "$connections"
    restored_slot=$(printf '%s\n' "$connections" | awk -v p="$plug" '$2 == p {print $3}')
    if [ "$restored_slot" != "$previous_slot" ]; then
        printf 'Original connection state was not restored.\n' >&2; exit 1
    fi
    exit "$original_status"
}
trap restore EXIT
trap 'exit 129' HUP
trap 'exit 130' INT
trap 'exit 143' TERM
sudo snap connect "$plug" "$slot"
snap connections "$app"
read -r -p 'Run your documented app test in another terminal; press Enter to restore: ' answer

Verify that an unconnected - becomes the actual Slot, then recheck the original state with snap connections APP_NAME after exit. The script disconnects only the requested Slot and queries the Plug again to verify its original unconnected state. Disconnection, inspection, or state-verification failures produce a nonzero exit status; an earlier exercise failure retains its status after successful restoration. Cleanup is also attempted on Ctrl+C and termination signals, but cannot cover power loss or every forced termination. Record the original Plug/Slot and restoration command. Check host file permissions and service policy separately.

The official Snap usage guide documents connection and disconnection commands.

Check updates, rollback, and removal data

You can request a refresh with sudo snap refresh app-name, after reviewing effects on running apps and services. Revision rollback does not guarantee backward-compatible application data and is not a substitute for backups.

Remove only the newly installed practice app with sudo snap remove hello-world. Inspect automatic data snapshots, when created, with snap saved and decide retention separately. Removing an app, retaining a snapshot, and deleting all user files are different operations.