Skip to main content
SysAdmin Shell Scripting Essentials

Install Deb File Ubuntu: CLI Command Reference, Syntax, Flags

install deb file ubuntu is the process of deploying a Debian package (.deb) on Ubuntu using apt, dpkg, or gdebi.

sudo apt install ./package.deb

This reference covers syntax, flags, and common pitfalls. All commands are verified against official documentation.

Common Mistakes When Installing .deb Files

  • Running apt install package.deb without ./: Without the path prefix, apt searches repositories for a package named package.deb and returns E: Unable to locate package.
  • Using dpkg -i directly on complex packages: Packages with multiple dependencies (e.g., Google Chrome, VS Code) cause dpkg to fail midway, leaving the system in a broken state that requires manual apt --fix-broken install.
  • Removing by .deb filename instead of package name: Running sudo apt remove ./package.deb fails because apt remove expects a repository package name, not a file path. Use sudo apt remove package-name instead.
  • Double-clicking on older Ubuntu versions without GDebi: On Ubuntu 18.04–20.04, the default Archive Manager extracts the .deb contents rather than installing the package. Install GDebi first to get a proper installer.
  • Ignoring architecture warnings: Installing an i386 .deb on an amd64 system silently fails unless multiarch support is enabled via sudo dpkg --add-architecture i386.
  • Using sudo apt install without ./ from a different directory: Running the command from ~/Downloads but referencing a file in /tmp with a relative path fails. Always provide the full path or ./filename.deb after cd to the correct directory.
See also  PowerShell Create a Directory: New-Item and mkdir Syntax & Error

Why .deb Installation Issues Occur on Ubuntu

  • Unresolved dependencies: The .deb file requires libraries not installed on the system, causing apt or dpkg to abort with a missing-dependency error.
  • Package architecture mismatch: A 64-bit .deb (amd64) cannot install on a 32-bit (i386) system or vice versa, resulting in an architecture mismatch error.
  • Version conflicts: An existing package with a higher version number prevents downgrades unless explicitly forced with --allow-downgrades.
  • Broken package state: Prior failed installations leave the system in an inconsistent state, blocking new installations until resolved with sudo apt --fix-broken install.
  • Missing prerequisites: Some .deb files require specific kernel modules, service managers, or runtime environments (e.g., systemd, Python 3.x) not present on the target system.
  • File corruption or incomplete download: A partially downloaded .deb file fails checksum validation, causing dpkg-deb: error: archive has premature member.
  • Permission issues: Running dpkg -i without sudo fails with dpkg: error: requested operation requires superuser privilege.

Tested on Ubuntu 22.04 LTS with apt 2.4.10, dpkg 1.21.1, and gdebi 0.9.5.7.

How to Install .deb Files on Ubuntu

  1. Install with apt (recommended): Navigate to the directory containing the .deb file and run sudo apt install ./package.deb. The ./ prefix forces apt to treat the argument as a local file path rather than a repository package name.
  2. Install with dpkg (low-level): Use sudo dpkg -i /path/to/package.deb when you need fine-grained control over package metadata. After installation, fix any dependency gaps with sudo apt --fix-broken install.
  3. Install with gdebi (dependency-aware): First install gdebi via sudo apt install gdebi, then run sudo gdebi package.deb. This tool resolves dependencies automatically without requiring a full repository update.
  4. Install via GUI: Double-click the .deb file. On current Ubuntu releases (22.04+), the App Center opens by default. Click Install and authenticate with your password. On older releases, the file opens in Ubuntu Software Center or Archive Manager.
See also  DHCP Leases in Linux: Management, Commands & Troubleshooting
Action CLI Command Key Flag Description
Install with apt sudo apt install ./package.deb -y Automatically answers yes to prompts; resolves dependencies from repos
Install with dpkg sudo dpkg -i package.deb -i Installs the package without dependency resolution
Fix broken deps sudo apt --fix-broken install -f Corrects dependency issues left by dpkg
Remove package sudo apt remove package-name -y Uninstalls the package by its name (not the .deb file)
Purge package sudo apt purge package-name -y Removes the package and its configuration files
Inspect .deb dpkg --info package.deb -I Displays package metadata without installing
List files in .deb dpkg --contents package.deb -c Lists all files the package will install

Frequently Asked Questions

What is the difference between ‘dpkg -i file.deb’ and ‘apt install ./file.deb’?

Answer: dpkg -i installs the package without dependency resolution; apt install ./file.deb automatically resolves and installs missing dependencies from configured repositories. Use dpkg -i only when all dependencies are already satisfied, then fix with sudo apt --fix-broken install if needed.

Example:

sudo apt install ./package.deb

For dpkg:

sudo dpkg -i package.deb

When should I use the ‘–force-depends’ flag with dpkg?

Answer: Use –force-depends only when you must force installation despite unsatisfied dependencies, typically in emergency recovery. This flag overrides dependency checks but can leave the system in an inconsistent state. Always follow up with sudo apt-get install -f to resolve dependencies.

Example:

sudo dpkg --force-depends -i bad-pkg.deb

Does ‘apt install ./file.deb’ work on all Ubuntu versions from 16.04 LTS to 24.04 LTS?

Answer: Yes, apt install ./file.deb works on Ubuntu 16.04 LTS and later. For older versions like 14.04, use sudo gdebi file.deb instead. Always verify architecture compatibility with dpkg --print-architecture before installing.

What is the fastest way to install a .deb file with automatic dependency resolution on Ubuntu?

Answer: sudo apt install ./package.deb is the fastest method because it resolves dependencies in one step. For offline environments, pre-fetch dependencies with apt-get download and then use dpkg -i.

Example:

sudo apt install ./app-1.0.deb