How To Run Deb File In Ubuntu

How To Run Deb File In Ubuntu

Reading time1 min
#Linux#Ubuntu#Software#Debian#PackageManagement#DPKG

Running .deb Packages on Ubuntu: Direct Installation with Dependency Control

Dealing with proprietary or third-party software on Ubuntu often means confronting the .deb file format directly, bypassing official repositories in favor of flexibility or necessity. The process isn’t always seamless; naively using graphical installers or the wrong command sequence can leave dependencies unresolved, destabilize your environment, or, at best, waste your time.

.deb Package Format: Brief Review

A .deb file is a structured archive containing compiled binaries and scripts intended for installation on Debian-based systems. Internally, it’s two tar archives (control, data) compressed, wrapped by an ar-format container. This format defines not just software delivery but the precise integration points into /usr/bin/, /usr/share/, executable stubs, and system configuration directories.

Typical Use-Cases for Direct .deb Installation

  • Vendor software (e.g., Google Chrome, proprietary network clients) is frequently distributed solely as .deb.
  • Beta or CI builds from upstream maintainers before repository approval.
  • Air-gapped environments where internet-based APT sources are inaccessible.
  • Rapid rollback or version pinning during troubleshooting.

Installation: Command-Line Is More Predictable Than GUI

The most deterministic method is through the shell:

# Download, e.g., current stable Chrome for amd64
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

Baseline Installation with dpkg

sudo dpkg -i google-chrome-stable_current_amd64.deb

Key points:

  • dpkg -i unpacks the control and data segments, then triggers post-install scripts.
  • It does not resolve unmet dependencies. Expect errors similar to:
dpkg: dependency problems prevent configuration of google-chrome-stable:
 google-chrome-stable depends on gconf-service; however:
  Package gconf-service is not installed.

To rectify these, immediately:

sudo apt-get install -f

The -f (“fix-broken”) flag will analyze outstanding dependencies from failed installs and attempt resolution via phased download and configuration.

Note: Inconsistent package states may lead to “dpkg was interrupted” errors; re-run sudo dpkg --configure -a if this appears.

Modern Alternative: apt install with a Local Path

APT version 1.1+ (Ubuntu 16.04 and onward) accepts local .deb paths:

sudo apt install ./google-chrome-stable_current_amd64.deb

This approach auto-resolves dependencies, honors configured pins, and logs events to /var/log/apt/term.log. For multi-package installs, pass several .deb in one command.

Table: dpkg vs apt install

CommandResolves DependenciesHandles Multiple DebsPreferred for Automation
dpkg -iNoYes (but same issues)No
apt install ./pkg.debYesYesYes

GUI Installation: Not Always Reliable

Double-clicking a .deb in Nautilus/Finder triggers the Ubuntu Software installer, which delegates installation to PackageKit or GNOME Software. While convenient:

  • Logs are opaque—see /var/log/syslog for issues.
  • Large interim downloads may stall.
  • Dependency errors often lack actionable detail.

Known issue: On Ubuntu 20.04 LTS, unfulfilled dependencies sometimes leave the GUI installer stuck.

Real-World Example: Installing VS Code

wget https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64 -O code_latest_amd64.deb
sudo apt install ./code_latest_amd64.deb

APT will fetch supporting packages (e.g., libasound2, libxss1) on demand.

Package Removal

Uninstall as follows:

sudo apt remove code
# or, to purge configuration files:
sudo apt purge code

apt tracks package origins; even manually-installed .deb can be cleanly managed post-facto.

Manual removal with dpkg is available but rarely necessary:

sudo dpkg -r code

Tip: APT resolves reverse dependencies; dpkg does not.

Inspection & Troubleshooting

Check package headers and metadata:

dpkg-deb -I code_latest_amd64.deb

List installed files for forensic purposes:

dpkg -L code

If you encounter misconfigured package states (e.g., interrupted transactions):

sudo dpkg --configure -a
sudo apt-get install -f

Non-obvious tip: For air-gapped systems, apt-offline or aptitude download can pre-fetch and package dependency trees for transfer.

Gaps & Trade-offs

Direct .deb installs can introduce state drift if upstream packages conflict with repo-managed files. Periodically apt update and audit /etc/apt/sources.list.d/ for third-party installs. For continuous deployment or CI pipelines, prefer building and distributing via PPA or hosting a local APT repo for traceability.

Summary

For rigorous systems administration—install .deb via apt install ./pkg.deb to ensure dependency trees are traversed and resolved automatically. Use dpkg -i only for very controlled deployments or debugging. Always validate source authenticity of any downloaded .deb, and correlate package hashes with official SHA256SUMS when possible.

Typical install pattern for current Ubuntu systems (22.04 LTS and newer):

wget <package_url>
sudo apt install ./<package>.deb

To recover from partial states:

sudo dpkg --configure -a
sudo apt-get install -f

This approach minimizes user intervention, surfaces interpretable logs, and ensures stability across upgrades and removals.