readlink on Linux shows where a symlink actually points — essential for nginx sites-enabled chains, Java alternatives, and “wrong binary” mysteries when which and ls -l disagree.
Symlink target
Without -f, readlink prints only the immediate link text.
bashtarget
readlink /usr/bin/python3

Canonical path
readlink -f (GNU) resolves all components — fails on missing final target.
bashcanonical
readlink -f /etc/alternatives/python3

Broken links
Non-existent targets error — that is the signal in health checks.
bashcheck
for l in /etc/alternatives/*; do readlink -f "$l" 2>/dev/null || echo "broken: $l"; done | head

Deploy scripts
Store real paths for systemd ExecStart to avoid PATH surprises.
WarningBusyBox readlink may lack
-f — use realpath where available on minimal images.
Quick Reference
- One hop:
readlink path - Full path:
readlink -f path - Breakage: stderr on missing target
Related tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.