dh_testroot - Linux


dh_testroot is a powerful command specifically designed for Debian package maintainers. It aids in testing the correctness and completeness of debian/rules files and associated scripts. This tool emulates the fakeroot environment within a temporary build directory, allowing developers to thoroughly verify the behavior of their packages without modifying the system.


dh_testroot [OPTIONS] [BUILD-DIR-PATH]


  • -a, –arch ARCH: Specifies the architecture to test against. Defaults to the current architecture.
  • -c, –clean: Removes the build directory before testing.
  • -d, –debug: Enables debugging output.
  • -f, –force: Forces testing, even if the package has already been built.
  • -g, –skip-build: Skips the build phase and only tests the install phase.
  • -h, –help: Displays the help message.
  • -i, –ignore-auto: Ignores automatic dependencies (Build-Depends-Indep and Build-Conflicts-Indep).
  • -k, –keep-build: Keeps the build directory after testing.
  • -m, –mode MODE: Specifies the test mode. Can be naive (default), full (recommended), or real.
  • -n, –no-lintian: Skips the lintian check.
  • -p, –package PACKAGE: Specifies the Debian package to test.
  • -q, –silent: Suppresses output unless there are errors.
  • -r, –root-cmd COMMAND: Specifies a command to run as root during the install phase.
  • -s, –seed SEED: Specifies a specific entropy seed for generating random numbers.
  • -u, –unfakeroot: Disables fakeroot mode.
  • -v, –verbose: Increases verbosity.


Basic Usage:


Test a specific package:

dh_testroot --package my-package

Force testing:

dh_testroot --force

Skip the build phase:

dh_testroot --skip-build

Common Issues

  • Missing dependencies: Ensure that all dependencies specified in debian/control are installed before running the test.
  • Build errors: Review the build output for errors and fix any issues before continuing with the test.
  • Lintian warnings: While lintian warnings are not fatal, it’s advisable to address them to improve the package quality.


dh_testroot can be integrated into automated testing frameworks to ensure consistent and reliable package testing. It can be combined with tools like bats or make for complex test scenarios.

Related Commands

  • dpkg-buildpackage: Builds a Debian package.
  • lintian: Checks Debian packages for common errors and policy violations.
  • dpkg-deb: Manipulates Debian package archives.