---
name: "dh_testroot"
section: "1"
platform: "linux"
package: "debhelper"
version: "13.24.2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dh_testroot"
---

# dh\_testroot(1)

ensure that a package is built with necessary level of root permissions

## NAME

dh\_testroot - ensure that a package is built with necessary level of root permissions

## SYNOPSIS

**dh\_testroot** \[*debhelper options*\]

## DESCRIPTION

**dh\_testroot** is used to determine if the target is being run with suffient access to root(-like) features.

The definition of sufficient access depends on whether the builder (the tool invoking the *debian/rules* target) supports the *Rules-Requires-Root* (R³) field.  If the builder supports R³, then it will set the environment variable *DEB\_RULES\_REQUIRES\_ROOT* and **dh\_testroot** will validate that the builder followed the minimum requirements for the given value of *DEB\_RULES\_REQUIRES\_ROOT*.

If the builder does not support *Rules-Requires-Root*, then it will not set the *DEB\_RULES\_REQUIRES\_ROOT* environment variable.  This will in turn make **dh\_testroot** (and the rest of debhelper) fall back to assuming that (fake)root is implied.

The following is a summary of how **dh\_testroot** behaves based on the *DEB\_RULES\_REQUIRES\_ROOT* environment variable (leading and trailing whitespace in the variable is ignored).

- \-

  If unset, or set to `"binary-targets"`, then **dh\_testroot** asserts that it is run as root or under [**fakeroot**(1)](/fakeroot/1.md).

- \-

  If set to `"no"`, then **dh\_testroot** returns successfully (without performing any additional checks).

- \-

  If set to any other value than the above, then **dh\_testroot** asserts that it is either run as root (or under [**fakeroot**(1)](/fakeroot/1.md)) or the builder has provided the **DEB\_GAIN\_ROOT\_CMD** environment variable (e.g. via dpkg-buildpackage -r).

Please note that **dh\_testroot** does *not* read the *Rules-Requires-Root* field.  Which implies that **dh\_testroot** may produce incorrect result if the builder lies in *DEB\_RULES\_REQUIRES\_ROOT*.  On the flip side, it also enables things like testing for what will happen when *DEB\_RULES\_REQUIRES\_ROOT* is set to a given value.

## SEE ALSO

[**debhelper**(7)](/debhelper/7.md)

This program is a part of debhelper.

## AUTHOR

Joey Hess \<joeyh@debian.org\>
