Using the dpkg-deb command (with examples)
Display information about a package
The dpkg-deb --info
command is used to display information about a specific Debian package. This includes details such as package name, version, architecture, dependencies, installed size, and more.
Code:
dpkg-deb --info path/to/file.deb
Motivation:
This command can be useful when you want to quickly check the details of a Debian package without installing it. It helps to gather information about a package before deciding to install or use it.
Explanation/Arguments:
--info
: This argument tells the dpkg-deb command to display information about the package.path/to/file.deb
: This is the path to the Debian package file for which you want to display information.
Example Output:
new debian package, version 2.0.
size 27426680 bytes: control archive=1571 bytes.
375 bytes, 15 lines control
1565 bytes, 29 lines md5sums
Package: example-package
Version: 1.0
Architecture: amd64
Maintainer: John Doe <john@example.com>
Installed-Size: 82601
...
Display the package’s name and version on one line
The dpkg-deb --show
command is used to display the name and version of a Debian package on a single line.
Code:
dpkg-deb --show path/to/file.deb
Motivation:
Sometimes, you may only be interested in knowing the name and version of a package without the additional details. This command provides a concise way to obtain the package’s basic information.
Explanation/Arguments:
--show
: This argument instructs the dpkg-deb command to display the package’s name and version.path/to/file.deb
: This is the path to the Debian package file for which you want to display the information.
Example Output:
example-package 1.0
List the package’s contents
The dpkg-deb --contents
command allows you to list the contents of a Debian package, including the files and directories it contains.
Code:
dpkg-deb --contents path/to/file.deb
Motivation:
This command can be useful when you want to know what files are included in a Debian package. It helps to identify which files will be installed on the system when the package is installed.
Explanation/Arguments:
--contents
: This argument tells the dpkg-deb command to list the contents of the package.path/to/file.deb
: This is the path to the Debian package file for which you want to list the contents.
Example Output:
drwxr-xr-x root/root 0 2021-01-01 12:00 ./
drwxr-xr-x root/root 0 2021-01-01 12:00 ./usr/
drwxr-xr-x root/root 0 2021-01-01 12:00 ./usr/bin/
-rwxr-xr-x root/root 1024 2021-01-01 12:00 ./usr/bin/example-executable
drwxr-xr-x root/root 0 2021-01-01 12:00 ./usr/share/
drwxr-xr-x root/root 0 2021-01-01 12:00 ./usr/share/doc/
-rw-r--r-- root/root 512 2021-01-01 12:00 ./usr/share/doc/example-package/README.md
...
Extract package’s contents into a directory
The dpkg-deb --extract
command is used to extract the contents of a Debian package into a specified directory.
Code:
dpkg-deb --extract path/to/file.deb path/to/directory
Motivation:
Sometimes, you may need to extract the contents of a Debian package without installing it. This command allows you to extract the package’s files and directories into a specific location for further examination or use.
Explanation/Arguments:
--extract
: This argument instructs the dpkg-deb command to extract the package’s contents.path/to/file.deb
: This is the path to the Debian package file that you want to extract.path/to/directory
: This is the destination directory where the contents of the package will be extracted.
Example Output:
No output will be displayed in the terminal. The package’s contents will be extracted to the specified directory.
Create a package from a specified directory
The dpkg-deb --build
command is used to create a Debian package from a specified directory.
Code:
dpkg-deb --build path/to/directory
Motivation:
This command is useful when you want to create a Debian package from custom-built software or scripts. It allows you to package your own applications and distribute them as Debian packages for easy installation and management.
Explanation/Arguments:
--build
: This argument tells the dpkg-deb command to create a package from the specified directory.path/to/directory
: This is the path to the directory containing the files and directories that you want to package.
Example Output:
No output will be displayed in the terminal. The command will create a Debian package file in the current directory with the naming convention: packagename_version_architecture.deb
.