.deb

The .deb installation package is a software package format used in Debian based operating systems such as Ubuntu, Linux Mint, and many others. It is a popular format for distributing and managing software.

Here are the details of the .deb package:


1. Structure of the .deb package

A .deb package is a compressed file, containing all the components needed to install a software. It usually includes:

  • control: Metadata files (information about the package):
  • Package name, version, description, required dependencies.
  • Example: The control file is defined as follows:
Package: example-package
Version: 1.0.0
Architecture: amd64
Maintainer: Example Team <[email protected]>
Description: Example package for demonstration
Depends: libc6 (>= 2.28), libssl1.1
  • data.tar: Contains executables, libraries, or configuration files that will be installed on the system.

  • Examples: /usr/bin, /etc/example.conf, or /usr/lib/example.

  • debian-binary: A small text file containing only the version of the Debian package (e.g., 2.0).


2. How to create and manage .deb packages

Creating .deb packages

You can create .deb packages from source code or from pre-prepared files:

  • Packaging tools:

  • dpkg-deb: Basic tool for packaging .deb files.

dpkg-deb --build <package_directory>
  • debuild: Usually used for packaging from source code.

  • dh_make: Tool to automate the creation of debian/control, rules files.

Sample Package Directory

A sample package directory for the example software has the following structure:

example/
├── DEBIAN/
│ ├── control # Package metadata
│ ├── postinst # Script to run after installation
│ ├── prerm # Script to run before uninstall
├── usr/
│ ├── bin/ # Executable file
│ ├── share/

3. Installing .deb

Using dpkg

Basic command to install .deb:

sudo dpkg -i package.deb

If you encounter a dependency error, run:

sudo apt --fix-broken install

Using apt or gdebi (automatic dependency resolution)

  • gdebi:
sudo apt install gdebi
sudo gdebi package.deb
  • apt:
sudo apt install ./package.deb

4. Remove the .deb package

If the package is already installed, you can remove it with:

  • dpkg:
sudo dpkg -r <package-name>
  • apt:
sudo apt remove <package-name>

If you want to remove the configuration file as well:

sudo apt purge <package-name>

5. Common errors when working with .deb

Dependency error

If a package requires other packages (dependencies) that are not installed:

sudo apt --fix-broken install

Incompatible architecture error

The .deb package is not compatible with your system architecture (e.g. installing amd64 on an arm64 system):

  • Check the architecture:
dpkg --print-architecture

Broken or incomplete package

If the installation stops midway:

sudo dpkg --configure -a

6. Advantages of .deb

  • Good integration on Debian-based systems: Package management systems like dpkg and apt have strong support.

  • Dependency management: Metadata in the package helps resolve dependencies automatically (with apt).

  • Customizable: You can add scripts for automation (e.g. postinst, prerm).


Check package information

  • Display .deb package information:
dpkg-deb -I package.deb
  • Check the contents of .deb package:
dpkg-deb -c package.deb

Check installed packages

dpkg -l

Find the location of installed files from the package

dpkg -L <package-name>

Uninstall package.deb