AI Crawler · Collection Records

Bot summary · Last 24 hours

readlink — Show symlink targets

Prints the target of a symlink, with -f resolving the full path.
Markdown source·Anything to add or correct?

Prints the target of a symlink, with -f resolving the full path.

Basic Information

Command Namereadlink
One-line IntroductionPrints the target of a symlink, with -f resolving the full path.
Provided byGNU coreutils (installed by default on all Linux distributions)
Official Documentationhttps://man7.org/linux/man-pages/man1/readlink.1.html
Supported Operating SystemsLinux, macOS, BSD, WSL
Installation StatusInstalled by default (no separate installation needed)
CategoryLinux file and disk management (tags: symlink, path, link)

What is this command?

readlink reads a symlink and prints its target. With -f it resolves every intermediate link into an absolute path.

It resembles realpath, but by default it shows the link target string as stored.

What problems does it solve?

  • You need to see what a link points to
  • A script must resolve its own real path
  • You need the final target of a link chain
  • You are testing whether a path is a link

Key features

Print the target

Shows the stored target string.

  • When to use: You inspect link structure
  • What you get: The target path string
  • Limitations: Relative links appear as relative paths.

Resolve fully

-f follows all links to an absolute path.

  • When to use: You need the exact script location
  • What you get: A resolved absolute path
  • Limitations: A missing final component causes failure.

Normalize only

-m normalizes even if components do not exist.

  • When to use: You handle paths not yet created
  • What you get: A normalized path
  • Limitations: It does not verify actual links.

Installation and usage

Check whether it is installed


readlink --version

sudo apt install coreutils # Debian/Ubuntu sudo dnf install coreutils # Fedora

Real-world examples

Inspect a link

Print the target of the link.


readlink /usr/bin/awk

Real script path

Get the real file path even via a symlink.


SCRIPT=$(readlink -f "$0")
echo "$SCRIPT"

Normalize a path

Normalize even when the path does not exist.


readlink -m ./build/../dist/app.tar.gz

Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/readlink.html This file is an auto-generated Markdown twin of the DevHub document.

Visitor Comments

Loading…
💬 Comments: 0 · Author type: human | Built: 2026-10-30T20:30:59+09:00