dh_strip - Linux


dh_strip is a Debian packaging tool that removes portions of code, especially symbols, normally kept for debugging purposes. This results in reduced file sizes and improved performance. It is commonly used during the build process of Debian packages to optimize them for production.


dh_strip [options] [target1 [target2 ...]]


  • -a, --all: Strip all debugging information.
  • -d, --debug: Remove only compiler-generated symbols.
  • -k, --keep: Keep symbols matching a given regular expression.
  • -p, --pattern: Strip symbols matching a given regular expression.
  • -v, --verbose: Enable verbose output, logging all actions performed.
  • --help: Display help information and exit.
  • --version: Display version information and exit.


Simple strip:

dh_strip --all

Strip only compiler-generated symbols:

dh_strip --debug

Strip all symbols except for those matching a pattern:

dh_strip -d --keep "^_main$"

Common Issues

  • Missing debug symbols: If a stripped binary is used for debugging purposes, debug symbols may be missing. Consider using strip --strip-unneeded instead of dh_strip --all to preserve needed symbols.
  • Symbol conflicts: If multiple libraries or executables are stripped using different patterns, symbol conflicts may occur. Use consistent patterns or use the --keep flag to avoid conflicts.


dh_strip integrates with Debian’s packaging system and is often used in debian/rules files to strip binaries during package build. It can also be combined with other tools like make for more complex build processes.

Related Commands

  • strip: The upstream version of dh_strip.
  • dpkg-deb: Debian package manipulation tool.
  • lintian: Debian package linter.