Ubuntu Command to Display Real Physical Path
This article explains how to identify the actual physical location of a file or directory in Ubuntu when symbolic links are involved. It covers the primary commands used to resolve these links to their absolute real paths, ensuring you know exactly where data resides on your disk regardless of shortcuts or pointers.
The primary command to display the real physical path resolving all
symlinks is realpath. This utility is included in the GNU
coreutils package and is pre-installed on Ubuntu. It canonicalizes the
filename by removing extra slashes, resolving relative paths, and
following all symbolic links to return the absolute pathname.
realpath /path/to/file_or_symlinkIf realpath is unavailable or you prefer an alternative,
use the readlink command with the -f flag.
While readlink alone only prints the value of a symlink,
the -f option forces it to resolve every symlink in the
path recursively until it reaches the actual file.
readlink -f /path/to/file_or_symlinkBoth commands produce the same output for most use cases. For
instance, if a symlink named config points to
/etc/app/settings.ini, running either command on
config will output /etc/app/settings.ini. Use
these tools in scripts or manual checks to verify the true location of
resources on your Ubuntu system.