Ubuntu & Linux Guide
Table of Contents
- Core Concepts
- Ubuntu Versions
- Package Management Systems
- APT Package Manager
- PPA (Personal Package Archives)
- Package Repositories
- Installation Methods Comparison
- APT Commands Reference
- Best Practices
- Troubleshooting
Core Concepts
The Linux Ecosystem Hierarchy
┌─────────────────────────────────────┐
│ Applications │ (Firefox, VS Code, VLC)
├─────────────────────────────────────┤
│ Package Managers (apt, snap) │ (Install/manage software)
├─────────────────────────────────────┤
│ Operating System (Ubuntu/Debian) │ (System utilities, GUI)
├─────────────────────────────────────┤
│ Linux Kernel (Core) │ (Hardware interface)
├─────────────────────────────────────┤
│ Hardware │ (CPU, RAM, Disk, Network)
└─────────────────────────────────────┘
Linux Kernel
Definition: The core of the operating system
Analogy: Like the engine of a car
Functions: - Interacts directly with computer hardware - Manages CPU, memory, and storage - Provides interface between software and hardware - Handles processes, file systems, and drivers
Debian
Definition: Complete operating system built on Linux kernel
Components: - Linux kernel - Package managers (apt, apt-get, dpkg) - Command-line tools (bash, grep, sed, awk) - GUI desktop environment (GNOME, KDE, XFCE) - System utilities and libraries - Default applications
Philosophy: - Free and open source - Stability-focused - Community-driven
Package Managers Explained
dpkg (Debian Package)
Definition: Low-level package manager for Debian-based systems
Characteristics: - ❌ Does NOT handle dependencies automatically - ✅ Installs/removes individual .deb files - ✅ Direct control over packages - ❌ Requires manual dependency resolution
Example:
# Install package (dependencies must be installed separately)
sudo dpkg -i package.deb
# Remove package
sudo dpkg -r package-name
# List installed packages
dpkg -l
apt (Advanced Packaging Tool)
Definition: High-level package manager that uses dpkg underneath
Characteristics: - ✅ Automatically resolves and installs dependencies - ✅ Downloads packages from repositories - ✅ Handles package upgrades - ✅ More user-friendly than dpkg
Relationship: apt → dpkg → Install package
Evolution:
- apt-get (older, still works)
- apt (newer, combines apt-get + apt-cache features, recommended)
Example:
# apt handles everything (downloads + dependencies)
sudo apt install vlc
# apt-get (older syntax, still works)
sudo apt-get install vlc
Ubuntu
Definition: Operating system based on Debian with additional functionality
Key Features: - Built on Debian foundation - More frequent releases (every 6 months) - More user-friendly - Better hardware support out-of-the-box - Corporate backing (Canonical)
Relationship: Ubuntu ⊃ Debian ⊃ Linux Kernel
Ubuntu Versions
Version Naming Convention
Ubuntu uses version numbers with memorable codenames (like Android).
| Version | Codename | Release Date | Support Until | LTS? |
|---|---|---|---|---|
| 24.04 | Noble Numbat | April 2024 | April 2029 | ✅ Yes |
| 23.10 | Mantic Minotaur | October 2023 | July 2024 | ❌ No |
| 22.04 | Jammy Jellyfish | April 2022 | April 2027 | ✅ Yes |
| 21.10 | Impish Indri | October 2021 | July 2022 | ❌ No |
| 20.04 | Focal Fossa | April 2020 | April 2025 | ✅ Yes |
| 18.04 | Bionic Beaver | April 2018 | April 2023 | ✅ Yes (ended) |
Understanding Version Numbers
24.04
││ ││
││ └└─ Month (04 = April)
└└──── Year (24 = 2024)
LTS (Long Term Support)
LTS versions (released every 2 years): - ✅ 5 years of support (security updates) - ✅ More stable - ✅ Recommended for production/servers - ✅ Released in April of even years (.04)
Regular versions (every 6 months): - ⚠️ 9 months of support only - ⚠️ Latest features but less stable - ⚠️ For enthusiasts and testing
Why Version Matters
Important: Software may require specific Ubuntu versions because: - Newer software needs newer libraries - Older versions may lack required dependencies - Package repositories vary by version
Example: QGIS 3.34 might need Ubuntu 22.04+ but won't work on 18.04
Package Management Systems
Ubuntu supports multiple package management systems, each with different approaches.
Comparison Table
| System | Type | Dependencies | Sandbox | Speed | Disk Space | Best For |
|---|---|---|---|---|---|---|
| APT | System | Shared libraries | ❌ No | Fast | Efficient | CLI tools, system packages |
| Snap | Universal | Bundled | ✅ Yes | Medium | Large | GUI apps (Ubuntu) |
| Flatpak | Universal | Bundled | ✅ Yes | Medium | Large | GUI apps (Community) |
| AppImage | Portable | Bundled | ✅ Yes | Fast | Medium | Portable apps |
Detailed Comparison
APT (Traditional)
How it works:
- Uses shared system libraries
- Like pip in Python (shared dependencies)
- Packages installed system-wide
Pros: - ✅ Small download/disk size - ✅ Fast installation - ✅ Well-integrated with system - ✅ Efficient resource usage
Cons: - ❌ Potential library conflicts - ❌ Can't install multiple versions - ❌ Requires root/sudo access
Analogy: Like using a shared toolbox - everyone shares the same tools (libraries).
Snap / Flatpak / AppImage (Sandboxed)
How they work:
- Bundle all dependencies with app
- Like venv in Python (isolated environment)
- Each app has its own libraries
Pros: - ✅ No dependency conflicts - ✅ Can install multiple versions - ✅ Latest versions available - ✅ Better security (sandboxed) - ✅ Cross-distribution compatible
Cons: - ❌ Larger download/disk size - ❌ Slower startup (sometimes) - ❌ Redundant libraries
Analogy: Like everyone having their own toolbox - no sharing, but no conflicts.
Snap vs Flatpak
| Feature | Snap | Flatpak |
|---|---|---|
| Maintained by | Canonical (Ubuntu) | Community |
| Philosophy | Controlled by company | Open community |
| Default on | Ubuntu | Many distros |
| Backend | snapd (proprietary server) | Flathub (open) |
| Analogy | Google Play Store | F-Droid |
Recommendation: - Flatpak - More community-driven, open - Snap - Better Ubuntu integration
AppImage
Unique features: - Single executable file - No installation needed - Truly portable (USB stick) - No root required
Use when: - Need portable version - Don't want to install - Official website provides AppImage
APT Package Manager
How APT Works
User Command (apt install vlc)
↓
APT searches repositories
↓
Downloads package + dependencies
↓
Calls dpkg to install
↓
Package installed system-wide
APT Security
Important: APT grants superuser access to entire system
⚠️ Security Rule: Only install packages from trusted sources - Official Ubuntu repositories: ✅ Safe - Well-known PPAs: ✅ Usually safe - Unknown sources: ❌ Risk
Basic APT Usage
# Update package lists (always do this first!)
sudo apt update
# Install packages
sudo apt install vlc
sudo apt install vlc libreoffice code # Multiple packages
# Install from .deb file
sudo apt install ./package.deb
# Install specific version
sudo apt install kicad=7.0.0-1ubuntu
PPA (Personal Package Archives)
What is PPA?
PPA = Personal Package Archive
Definition: Third-party software repository hosted on Launchpad.net
Purpose: Allows developers to distribute software outside official Ubuntu repositories
Why PPAs Exist
Problem:
Developer releases new version
↓
Submit to Ubuntu maintainers
↓
Wait weeks/months for approval
↓
Finally available in apt
Solution with PPA:
Developer releases new version
↓
Upload to personal PPA
↓
Immediately available to users
PPA Analogy
Official APT: Like Google Play Store (curated, slow updates) PPA: Like F-Droid (third-party, faster updates, no fees)
Using PPAs
# Add PPA repository
sudo add-apt-repository ppa:username/ppa-name
# Update package lists
sudo apt update
# Install from PPA
sudo apt install package-name
# Example: KiCAD PPA
sudo add-apt-repository ppa:kicad/kicad-7.0-releases
sudo apt update
sudo apt install kicad
PPA Version Priority
If package exists in both APT and PPA: - Highest version wins - PPA usually has newer versions
Example:
APT repository: kicad 6.0.0
PPA repository: kicad 7.0.0
Installed: kicad 7.0.0 (from PPA)
Managing PPAs
# List PPAs
ls /etc/apt/sources.list.d/
# Remove PPA
sudo add-apt-repository --remove ppa:username/ppa-name
# Alternative: delete PPA file
sudo rm /etc/apt/sources.list.d/ppa-name.list
sudo apt update
Package Repositories
Ubuntu organizes packages into different repositories based on licensing and maintenance.
Repository Categories
| Repository | License | Maintained By | Support | Examples |
|---|---|---|---|---|
| main | Open Source | Ubuntu (Canonical) | ✅ Official | bash, apt, python3, Firefox, LibreOffice, GNOME |
| universe | Open Source | Community | ⚠️ Community | KiCad, VLC, GIMP, Arduino, FreeCAD, Inkscape |
| multiverse | Closed Source | Community | ⚠️ Community | RAR, Steam, MS Core Fonts |
| restricted | Closed Source | Ubuntu | ✅ Official | Intel firmware, WiFi drivers, NVIDIA drivers |
| PPA | Varies | Third-party | ❌ No guarantee | KiCad latest, QGIS, VS Code, Wine |
Repository Details
main
- License: Free and Open Source (FOSS)
- Quality: Highest
- Support: Full Ubuntu support
- Updates: Regular security updates
- Contains: Core system components
Examples: - System tools (bash, grep, sed) - Programming languages (python3, gcc) - Core applications (Firefox, LibreOffice) - Desktop environments (GNOME, Ubuntu Desktop)
universe
- License: Free and Open Source (FOSS)
- Quality: Good
- Support: Community-maintained
- Updates: Best-effort basis
Examples: - Development tools (Arduino IDE, FreeCAD) - Multimedia (VLC, GIMP, Inkscape) - Engineering (KiCad, OpenSCAD)
multiverse
- License: Proprietary/Closed Source
- Quality: Varies
- Support: Limited
- Legal: May have restrictions in some countries
Examples: - Codecs (MP3, DVD) - Commercial software (Steam, Skype) - Proprietary fonts (MS TrueType fonts)
restricted
- License: Proprietary/Closed Source
- Quality: High (drivers)
- Support: Ubuntu maintains
- Purpose: Hardware compatibility
Examples: - Graphics drivers (NVIDIA proprietary) - WiFi firmware (Broadcom, Intel) - Microcode updates
Checking Package Repository
# Show package information (includes repository)
apt show firefox
# Search package origin
apt-cache policy firefox
Installation Methods Comparison
Decision Tree
Need to install software?
│
├─ Command-line tool? → APT
│
├─ Official AppImage available? → AppImage
│
├─ GUI app?
│ ├─ Available in APT? → APT
│ ├─ Need sandboxing/isolation? → Flatpak (1st) or Snap (2nd)
│ └─ Need latest bleeding-edge? → Flatpak/Snap
│
└─ Portable/temporary use? → AppImage
Recommended Method by Use Case
| Use Case | Method | Reason |
|---|---|---|
| System utilities | APT | Native integration |
| Development tools | APT | Performance |
| CLI applications | APT | Standard location |
| GUI applications | Flatpak > Snap > APT | Isolation, latest version |
| Testing software | AppImage | No installation |
| Portable apps | AppImage | Run from USB |
| Server software | APT | Stability |
| Latest bleeding-edge | Flatpak/Snap | Newest versions |
Thumb Rule Summary
APT → Command-line tools, system software
AppImage → If official AppImage available
Flatpak → GUI apps (community-driven, recommended)
Snap → GUI apps (Ubuntu-integrated, alternative)
APT Commands Reference
Command Syntax
apt command
apt [options] command
apt [options] command package1
apt [options] command package1 package2 package3
Essential Commands
Update and Upgrade
# Download package information from all sources (including PPAs)
# ⚠️ Always run this first!
sudo apt update
# Upgrade all installed packages
sudo apt upgrade
# Upgrade with smart conflict resolution
sudo apt full-upgrade
# Distribution upgrade (major version)
sudo apt dist-upgrade
Install and Remove
# Install single package
sudo apt install package-name
# Install multiple packages
sudo apt install package1 package2 package3
# Install from .deb file
sudo apt install ./downloaded-package.deb
# Install specific version
sudo apt install package-name=version-number
# Reinstall package (if corrupted)
sudo apt install --reinstall package-name
# Remove package (keep configuration files)
sudo apt remove package-name
# Remove package and configuration files
sudo apt purge package-name
# Remove package with dependencies
sudo apt autoremove package-name
Search and Information
# Search for packages (name and description)
apt search keyword
# Search for packages (name only)
apt search --names-only keyword
# Show package information
apt show package-name
# List all available packages
apt list
# List installed packages
apt list --installed
# List upgradable packages
apt list --upgradable
# Find package by file
apt-file search /path/to/file
Package Information
# Show package dependencies
apt depends package-name
# Show reverse dependencies (what depends on this)
apt rdepends package-name
# Show package details (version, size, description)
apt-cache show package-name
# Check package version
apt-cache policy package-name
Cleanup
# Remove unused dependencies
sudo apt autoremove
# Clean downloaded package files (cache)
sudo apt clean
# Clean old package files only
sudo apt autoclean
Advanced Commands
# Download package without installing
apt download package-name
# Simulate installation (dry run)
apt install -s package-name
# Fix broken dependencies
sudo apt --fix-broken install
# Reconfigure package
sudo dpkg-reconfigure package-name
Common Workflows
Install New Software
# 1. Update package lists
sudo apt update
# 2. Search for package
apt search software-name
# 3. View package info
apt show package-name
# 4. Install package
sudo apt install package-name
Complete System Update
# Update package lists
sudo apt update
# Upgrade packages
sudo apt upgrade
# Remove unused dependencies
sudo apt autoremove
# Clean package cache
sudo apt autoclean
Fix Broken Installation
# Fix broken dependencies
sudo apt --fix-broken install
# Reconfigure packages
sudo dpkg --configure -a
# Force package reinstall
sudo apt install --reinstall package-name
Best Practices
Regular Maintenance
# Weekly: Update system
sudo apt update && sudo apt upgrade
# Monthly: Clean up
sudo apt autoremove
sudo apt autoclean
# Check for security updates
sudo apt list --upgradable | grep -i security
Safety Tips
-
Always update before installing
bash sudo apt update sudo apt install package-name -
Review what will be installed
bash apt show package-name # Check before installing -
Be careful with PPAs
- Only add trusted PPAs
- Check reviews and reputation
-
Prefer official PPAs from software developers
-
Backup before major changes ```bash # Create package list backup dpkg --get-selections > package-backup.txt
# Restore packages sudo dpkg --set-selections < package-backup.txt sudo apt-get dselect-upgrade ```
- Don't mix package managers
- Use one primary method per app
- Avoid installing same app via APT and Snap
Performance Tips
# Clean package cache to free space
sudo apt clean
# Remove old kernels (keep 2-3 latest)
sudo apt autoremove --purge
# Speed up apt with parallel downloads
# Edit: /etc/apt/apt.conf.d/99custom
Acquire::Queue-Mode "host";
Acquire::http::Pipeline-Depth "5";
Troubleshooting
Common Issues
"Unable to locate package"
Problem: Package not found in repositories
Solutions:
# 1. Update package lists
sudo apt update
# 2. Check if package exists
apt search package-name
# 3. Check spelling and availability
apt-cache search package-name
# 4. Enable additional repositories
sudo add-apt-repository universe
sudo apt update
# 5. Check Ubuntu version compatibility
lsb_release -a
"Broken packages" or "Dependency issues"
Solutions:
# Fix broken packages
sudo apt --fix-broken install
# Clean and retry
sudo apt clean
sudo apt update
sudo apt upgrade
# Force package reconfiguration
sudo dpkg --configure -a
# Last resort: force install
sudo apt install -f
"Could not get lock"
Problem: Another apt process running
Solutions:
# Check running apt processes
ps aux | grep -i apt
# Wait for other process to finish, or:
# Remove lock files (use with caution!)
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock*
# Reconfigure dpkg
sudo dpkg --configure -a
Repository/PPA Issues
# List all repositories
ls /etc/apt/sources.list.d/
# Disable problematic PPA
sudo add-apt-repository --remove ppa:name/ppa
# Or edit directly
sudo nano /etc/apt/sources.list
# Update after changes
sudo apt update
Disk Space Issues
# Check disk space
df -h
# Find large packages
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
# Clean package cache
sudo apt clean
sudo apt autoclean
# Remove old kernels
sudo apt autoremove --purge
# Remove orphaned packages
sudo deborphan | xargs sudo apt-get -y remove --purge
Quick Reference
Most Used Commands
sudo apt update # Update package lists
sudo apt upgrade # Upgrade packages
sudo apt install pkg # Install package
sudo apt remove pkg # Remove package
sudo apt search keyword # Search packages
apt show pkg # Package info
apt list --installed # List installed
sudo apt autoremove # Clean dependencies
Package Sources Priority
1. Official repositories (main, universe)
2. Restricted/multiverse
3. PPAs
4. Manual .deb files
File Locations
/etc/apt/sources.list # Main repository list
/etc/apt/sources.list.d/ # Additional repositories (PPAs)
/var/cache/apt/archives/ # Downloaded packages
/var/lib/apt/lists/ # Package lists
/var/lib/dpkg/status # Installed packages info
Additional Resources
- Ubuntu Official Documentation: help.ubuntu.com
- Debian APT Guide: wiki.debian.org/Apt
- Package Search: packages.ubuntu.com
- Launchpad PPAs: launchpad.net
- Ubuntu Forums: ubuntuforums.org
- Ask Ubuntu: askubuntu.com
Happy Ubuntu computing! 🐧✨