dpkg-deb - Debian Package Archive Tool

Learn to use dpkg-deb for building, listing, and extracting Debian package archives (.deb). Master DEB package manipulation for Linux.

dpkg-deb - Debian Package Archive Tool

The dpkg-deb command is a powerful utility for manipulating Debian package archives (.deb files). It allows developers and system administrators to build, inspect, and extract the contents of Debian packages, which are fundamental to package management on Debian-based Linux distributions like Ubuntu.

Build Debian Packages

Use dpkg-deb -b to construct a .deb package from a specified directory. This is essential for creating your own software packages for Debian systems.

# Build a DEB package using the provided directory.
dpkg-deb -b /path/to/directory

List DEB Package Contents

The dpkg-deb -c option enables you to view the files contained within an existing .deb archive without extracting them. This is useful for understanding the structure of a package.

# List out the contents of an existing DEB package.
dpkg-deb -c /path/to/package.deb

Extract DEB Package Contents

With dpkg-deb -x, you can extract all files from a .deb package to a specified destination directory. If no destination is given, files are extracted to the current working directory.

# Extract the contents of an existing DEB package. If no destination is
# provided for the extracted files, then they will be extracted to the CWD.
# Will also create the specified directory if it's not found, but it won't
# create its parents.
dpkg-deb -x /path/to/package.deb /path/to/destination/

Query Package Sections

While not directly a dpkg-deb function, dpkg-query can be used in conjunction to understand package metadata, such as available sections for package categorization.

# Output (unique) list of available sections under which to create DEB package.
awk '!A[$1]++{print($1)}' <<< "$(dpkg-query --show -f='${Section}\n')"

Further Resources