Lesson 6.2: Flatpak Applications

Flatpak is a universal application deployment system for Linux. It provides sandboxed applications that work across different distributions, making it perfect for modern GUI applications.

Why Flatpak? Flatpak isolates applications from the system, provides consistent runtime environments, and allows developers to distribute apps that work on any Linux distribution.

Understanding Flatpak

Flatpak uses a different approach than traditional package managers:

Installing Flatpak

Flatpak is usually pre-installed on Ubuntu, but if not:

$ sudo apt update $ sudo apt install flatpak

Install GNOME Software Integration

For better integration with Ubuntu's software center:

$ sudo apt install gnome-software-plugin-flatpak

Flatpak Basics

Core Flatpak concepts and commands:

Remotes

Remotes are repositories that host Flatpak applications:

# Add Flathub (main repository) $ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo # List remotes $ flatpak remotes Name Options flathub system

Search Applications

Find applications in configured remotes:

$ flatpak search firefox Application ID: org.mozilla.firefox org.mozilla.firefoxbeta Description: Mozilla Firefox web browser Application ID: org.libreoffice.LibreOffice org.libreoffice.LibreOfficeDev Description: LibreOffice is a powerful office suite

Install Applications

Install applications using their application ID:

$ flatpak install flathub org.mozilla.firefox Looking for matches… Similar refs found for 'org.mozilla.firefox' in remote 'flathub' (system): 1/x86_64 org.mozilla.firefox/stable 2/x86_64 org.mozilla.firefox/beta Choose a ref number: 1 Required runtime for org.mozilla.firefox/x86_64/stable: org.freedesktop.Platform/x86_64/22.08 org.freedesktop.Sdk/x86_64/22.08 Installing: org.freedesktop.Platform/x86_64/22.08... Installing: org.mozilla.firefox/x86_64/stable...

Run Applications

Launch installed Flatpak applications:

# Run by application ID $ flatpak run org.mozilla.firefox # Run by name (if unique) $ flatpak run firefox # Applications also appear in application menu

Managing Flatpak Applications

Update, remove, and manage your Flatpak installations:

List Installed Applications

$ flatpak list Name Application ID Version Branch Installation Firefox org.mozilla.firefox 119.0.2 stable system LibreOffice org.libreoffice.LibreOffice 7.6.2.1 stable system GIMP org.gimp.GIMP 2.10.34 stable system

Update Applications

# Update all applications $ flatpak update Looking for updates… org.mozilla.firefox/x86_64/stable flathub 119.0.2 -> 120.0 org.libreoffice.LibreOffice/x86_64/stable flathub 7.6.2.1 -> 7.6.3 # Update specific application $ flatpak update org.mozilla.firefox

Remove Applications

$ flatpak uninstall org.mozilla.firefox Uninstalling: org.mozilla.firefox/x86_64/stable # Remove unused runtimes $ flatpak uninstall --unused

Flatpak vs Traditional Packages

Understanding when to use Flatpak vs APT:

Use Flatpak For:

Use APT For:

Flatpak Permissions

Flatpak applications run with limited permissions:

Permission Types

Managing Permissions

# Show application permissions $ flatpak info --show-permissions org.mozilla.firefox # Override permissions (advanced) $ flatpak override --filesystem=home org.mozilla.firefox # Reset permissions $ flatpak override --reset org.mozilla.firefox

Flatpak Runtimes

Runtimes provide shared libraries for applications:

Understanding Runtimes

Managing Runtimes

# List installed runtimes $ flatpak list --runtimes # Remove unused runtimes $ flatpak uninstall --unused # Show runtime information $ flatpak info --show-runtime org.freedesktop.Platform

Popular Flatpak Applications

Common applications available via Flatpak:

Web Browsers

Productivity

Development

Flatpak Configuration

Customize Flatpak behavior:

User vs System Installation

# Install for current user only $ flatpak install --user flathub org.mozilla.firefox # Install system-wide (requires sudo) $ sudo flatpak install flathub org.mozilla.firefox # List user installations $ flatpak list --user # List system installations $ flatpak list --system

Configuration Files

Flatpak stores configuration in:

Troubleshooting Flatpak

Common issues and solutions:

Application Won't Start

# Check application info $ flatpak info org.mozilla.firefox # Check for missing permissions $ flatpak run --command=ls org.mozilla.firefox # Run with more verbose output $ flatpak run --verbose org.mozilla.firefox

Graphics Issues

# Run with GPU access $ flatpak run --device=dri org.mozilla.firefox # Check graphics drivers $ flatpak glinfo

Network Issues

# Allow network access $ flatpak override --share=network org.mozilla.firefox # Check network permissions $ flatpak info --show-permissions org.mozilla.firefox

Practice Exercises

Exercise 1: Basic Flatpak Usage

  1. Add Flathub repository
  2. Search for a text editor
  3. Install the text editor
  4. Run the application
  5. List installed applications
Click for solution
$ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo $ flatpak search text editor $ flatpak install flathub org.gnome.gedit $ flatpak run org.gnome.gedit $ flatpak list

Exercise 2: Application Management

  1. Install multiple applications
  2. Update all Flatpak applications
  3. Check application permissions
  4. Remove one application
  5. Clean up unused runtimes
Click for solution
$ flatpak install flathub org.mozilla.firefox org.libreoffice.LibreOffice $ flatpak update $ flatpak info --show-permissions org.mozilla.firefox $ flatpak uninstall org.mozilla.firefox $ flatpak uninstall --unused

What's Next?

Now that you understand Flatpak, let's explore Snap packages, Canonical's containerized application system!

Continue to Snap Packages

Key Takeaways

  • Flatpak provides sandboxed, universal applications
  • Applications run in isolated environments
  • Flathub is the main repository for applications
  • Use Flatpak for modern GUI applications
  • Permissions control application access to system
  • Works across all Linux distributions