Snap, Flatpak, and AppImage
Snap, Flatpak, and AppImage#
Concepts#
Beyond APT — Universal Package Formats#
APT and .deb packages are the traditional way to install software on Debian/Ubuntu. But they have a limitation: packages are built for a specific distribution version. A .deb built for Ubuntu 24.04 may not work on Debian 12 or Ubuntu 22.04.
Universal package formats solve this by bundling the application with its dependencies, running in a sandbox, and working across distributions:
| Format | Developer | Sandbox | Auto-updates | Store | Installed on Ubuntu 24.04 | Installed on Debian 12 |
|---|---|---|---|---|---|---|
| Snap | Canonical | Yes (AppArmor + seccomp) | Yes | Snap Store | Yes (default) | No (can install) |
| Flatpak | Community (freedesktop.org) | Yes (Bubblewrap) | Yes (with config) | Flathub | No (can install) | No (can install) |
| AppImage | Community | No | No | None (download files) | N/A (no install needed) | N/A |
Snap#
Snap is Canonical’s packaging system. On Ubuntu 24.04, several default applications are Snaps (Firefox, Thunderbird, the Software Center).
How Snaps Work#
- Each Snap is a self-contained package (a
.snapfile, actually a SquashFS image). - Snaps are mounted as loopback devices (you will see them in
dfandmountoutput). - Snaps run in a sandbox with limited system access (controlled by “interfaces”).
- The
snapddaemon manages installation, updates, and confinement. - Snaps auto-update in the background.
Using Snap#
# Search for a snap
snap find "text editor"
# Get info about a snap
snap info vlc
# Install a snap
sudo snap install vlc
# List installed snaps
snap list
# Update all snaps
sudo snap refresh
# Update a specific snap
sudo snap refresh vlc
# Remove a snap
sudo snap remove vlc
# See snap connections (permissions)
snap connections vlc
Snap Confinement Levels#
| Level | Description |
|---|---|
| strict | Full sandbox. Can only access what interfaces allow. (Default for most snaps.) |
| classic | No sandbox. Full access to the system, like a .deb package. (e.g., VS Code, some IDEs.) |
| devmode | For development. Sandbox violations are logged but allowed. |
# Install a classic snap (requires --classic flag)
sudo snap install code --classic
Known Snap Quirks#
- Startup time: Snaps can be slower to start than
.debpackages (SquashFS decompression). - Disk usage: Each Snap bundles its dependencies, using more disk space.
- Loopback devices:
dfandmountshow many/snap/...entries — these are normal. - Theme integration: Snaps may not follow your system’s GTK/Qt theme perfectly.
- Home directory access: Strict snaps cannot access hidden directories in
~by default.
Flatpak#
Flatpak is a community-driven alternative to Snap. It is not pre-installed on Ubuntu or Debian but is easy to set up.
Installing Flatpak#
# Ubuntu 24.04
sudo apt install flatpak
# Debian 12
sudo apt install flatpak
# Add the Flathub repository (the main source of Flatpak apps)
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Restart your session (log out and back in) for Flatpak apps to appear in menus
Using Flatpak#
# Search for an app
flatpak search gimp
# Install an app
flatpak install flathub org.gimp.GIMP
# List installed apps
flatpak list
# Run an app
flatpak run org.gimp.GIMP
# Update all Flatpak apps
flatpak update
# Remove an app
flatpak uninstall org.gimp.GIMP
# Remove unused runtimes (shared dependencies)
flatpak uninstall --unused
Flatpak apps use a reverse-DNS naming convention: org.gimp.GIMP, org.mozilla.firefox, com.spotify.Client.
Flatpak vs Snap#
| Aspect | Snap | Flatpak |
|---|---|---|
| Primary store | Snap Store (Canonical-controlled) | Flathub (community-governed) |
| Server-side apps | Yes (e.g., Docker, LXD) | No (desktop apps only) |
| Auto-updates | Yes (forced) | Configurable |
| Backend store | Proprietary (Snap Store) | Open (Flathub, or host your own) |
| Desktop integration | Improving, sometimes rough | Generally better |
| Pre-installed on Ubuntu | Yes | No |
AppImage#
AppImage is the simplest approach: a single executable file that contains the entire application. No installation, no package manager, no root required.
Using AppImages#
# 1. Download an AppImage from the app's website
# (Example: downloading a hypothetical app.AppImage)
# 2. Make it executable
chmod +x app.AppImage
# 3. Run it
./app.AppImage
That is it. No sudo, no repositories, no dependencies to install.
AppImage Properties#
- Portable — works on any Linux distribution (that meets minimum library requirements).
- No installation — just run the file. Delete it to “uninstall.”
- No sandbox — runs with your full user permissions (no isolation).
- No auto-updates — you must manually download new versions (some AppImages include an update mechanism).
- No central store — download from the application’s website or AppImageHub.
- Desktop integration — not automatic. You must create
.desktopfiles manually if you want menu entries.
When to Use What#
| Scenario | Recommended |
|---|---|
| System tools, libraries, CLI tools | apt (always first choice) |
| Desktop app available as Snap on Ubuntu | Snap (already configured) |
| Desktop app not in apt repos | Flatpak (from Flathub) |
| Quick one-off use of an app | AppImage |
| Server-side software | apt or Snap (never Flatpak) |
| You want maximum isolation | Flatpak or Snap (strict) |
General rule: Use apt when possible. Use Snap/Flatpak for desktop apps that need newer versions or are not in the repositories. Use AppImage for portable, one-off use.
Lab#
Exercise 1: Explore Snaps (Ubuntu)#
# List installed snaps
snap list
# Notice the loopback mounts
df -h | grep snap | head -5
# Get info about an installed snap
snap info firefox # or another snap from the list
# Search for a snap
snap find "media player"
Exercise 2: Install and Remove a Snap#
# Install a snap
sudo snap install htop
# Run it
htop
# Press q to quit
# Check connections (permissions)
snap connections htop
# Remove it
sudo snap remove htop
Exercise 3: Set Up Flatpak#
# Install Flatpak
sudo apt install -y flatpak
# Add Flathub
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Note: you may need to log out and back in for full desktop integration
Exercise 4: Install a Flatpak App#
# Search for an app
flatpak search calculator
# Install GNOME Calculator (as a Flatpak)
flatpak install -y flathub org.gnome.Calculator
# Run it
flatpak run org.gnome.Calculator
# List installed Flatpaks
flatpak list
# Remove it
flatpak uninstall -y org.gnome.Calculator
# Clean up unused runtimes
flatpak uninstall --unused -y
Exercise 5: Use an AppImage#
# Create a simple test to understand AppImages
# We'll make a minimal "fake" AppImage to demonstrate the concept
mkdir -p ~/lab/appimage
cd ~/lab/appimage
# Create a shell script that acts like an AppImage
cat > myapp.AppImage << 'EOF'
#!/bin/bash
echo "Hello from AppImage!"
echo "I am running as: $(whoami)"
echo "My location: $0"
echo "No installation needed!"
EOF
chmod +x myapp.AppImage
./myapp.AppImage
# Clean up
cd ~
rm -rf ~/lab/appimage
Exercise 6: Compare Package Sizes#
# See how much space snaps use
snap list
du -sh /snap/ 2>/dev/null
# See how much space .deb packages use
dpkg-query -W --showformat='${Installed-Size}\t${Package}\n' | sort -rn | head -10
# Shows the 10 largest installed .deb packages (size in KB)
Review#
1. What problem do Snap, Flatpak, and AppImage solve compared to .deb packages?
They provide distribution-independent packaging. A .deb is built for a specific distro version, while Snap/Flatpak/AppImage bundle their dependencies and work across multiple distributions and versions.
2. What is the key difference between Snap and Flatpak?
Snap is controlled by Canonical (the Snap Store is proprietary) and supports both desktop and server apps. Flatpak is community-governed (Flathub), is fully open-source, and focuses on desktop applications only.
3. What does "strict confinement" mean for a Snap?
The Snap runs in a sandbox and can only access system resources explicitly allowed by its declared “interfaces.” It cannot freely access your files, hardware, or other applications without permission.
4. How do you "install" an AppImage?
You do not install it in the traditional sense. You download the AppImage file, make it executable (chmod +x), and run it directly. No package manager or root privileges are needed.
5. What is a downside of AppImages compared to Snap/Flatpak?
AppImages have no sandboxing (they run with full user permissions), no automatic updates, and no central management. Each AppImage must be updated manually.
6. When should you prefer `apt` over Snap/Flatpak?
When the package is available in the official repositories and the version meets your needs. apt packages are typically better integrated with the system, smaller, faster to start, and have consistent update management through apt upgrade.
Previous: Repositories, PPAs, and Backports | Next: Building from Source