Resolve and display the target of a symbolic link.
low risk
readlink prints the target of a symlink. The -f flag canonicalizes the entire path, resolving all nested symlinks and relative components — essential for finding the true absolute path of any file.
| Flag | Meaning |
|---|---|
-f --canonicalize | Resolve all symlinks to absolute path |
-e --canonicalize-existing | Canonicalize, fail if path doesn't exist |
-m --canonicalize-missing | Canonicalize even if path doesn't exist |
readlink /usr/bin/python3Show where python3 symlink points · explain & risk-check →readlink -f /etc/nginx/sites-enabled/appResolve full canonical path · explain & risk-check →readlink -f $0Get absolute path of current script · explain & risk-check →Use `readlink -f $0` at the top of shell scripts to get the script's actual directory regardless of how it was invoked — essential for portable scripts.
Reference text is hand-written and may be incomplete — check man readlink for your version. Test destructive commands on a non-production system first.