dh_testdir - Linux


dh_testdir is a command used for Debian packaging. It generates a directory containing examples for every template of a Debian control file. This directory can be used to test the templates by installing the packages created from them.


dh_testdir [debhelper options] [--buildsys-flags=flags] [--builddep-flags=flags] [controlfile ...]


  • --buildsys-flags: Flags passed to dh_buildsystem.
  • --builddep-flags: Flags passed to dh_builddep.
  • --force: Overwrite the directory even if it already exists.
  • --sourcedir: Specify the directory containing the source packages to test. The default is the current directory.
  • --testsuite=<suite>: Specify a suite to generate an example package for. The default is testing.


To create a test directory for the control file in the current directory:


To create a test directory for the control file in the /tmp directory:

dh_testdir --sourcedir=/tmp

Common Issues

If you encounter the error dh_testdir: command not found, ensure that the debhelper package is installed.


dh_testdir can be used with other Debian packaging tools such as dh_make, dh_buildsystem, and dh_installdeb.

Related Commands

  • dh_make: Provides a consistent way to create Debian packages.
  • dh_buildsystem: Generates the necessary files for building packages.
  • dh_installdeb: Installs a Debian package from a file.