dpkg-realpath - Linux


dpkg-realpath resolves symbolic links or other indirections in a file path given as an argument. It is a command-line tool used primarily within the Debian package management system to resolve paths to actual files or directories.


dpkg-realpath [options] [file ...]


  • –canonicalize (-C): Canonicalizes paths by removing duplicate path elements and resolving symlinks.
  • –expand-symlinks (-e): Expands symlinks in paths.
  • –list (-l): Lists each symlink in a path, as well as its target.
  • –help (-h): Displays help information.


  • Resolve a symlink:

    dpkg-realpath /path/to/symlink
  • Canonicalize a path:

    dpkg-realpath --canonicalize /path/to/file
  • Expand symlinks while listing each one:

    dpkg-realpath --list -e /path/to/linked/file

Common Issues

  • Path not found: Ensure the path specified actually exists.
  • Permission denied: Check file permissions and ensure you have read access to the specified path.
  • Symbolic link loop: If a loop exists in the symbolic links, dpkg-realpath will continuously follow the loop.


dpkg-realpath can be used in scripts or command chains to handle paths involving symbolic links or indirections. For example:

  • Check if a file is a symbolic link:
    if [ "$(dpkg-realpath /path/to/file)" != "/path/to/file" ]; then
      echo "File is a symlink"

Related Commands

  • readlink: Reads the target of a symbolic link.
  • realpath: Similar to dpkg-realpath, but part of the GNU Coreutils package.
  • find: Finds files or directories based on various criteria, including symbolic links.