readlink(1)

readlink1

Display target of symbolic link on standard output

Usage

readlink [-fn] file

Overview

The readlink utility when invoked with the pathname of a symbolic link as its argument dereferences the symbolic link and prints the name of target on standard output. If the -f option is not specified and readlink is invoked with an argument other than the pathname of a symbolic link, it exits with a nonzero exit code without printing anything.

The options are as follows:

-f

Canonicalize by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths and return the absolute pathname corresponding to file. The argument does not need to be a symbolic link.

-n

Do not print a trailing newline character.

Exit status

The readlink utility exits 0 on success, and >0 if an error occurs.

Releases

60 releases since OpenBSD 2.2; the text changed 9 times.

  1. 2.2–2.3
  2. 2.4–2.6
  3. 2.7–2.8
  4. 2.9–3.3
  5. 3.4–3.7
  6. 3.8–4.1
  7. 4.2–4.4
  8. 4.5–4.8
  9. 4.9–7.0
  10. 7.1–8.0

History

The readlink utility first appeared in OpenBSD 2.1.

From man 8.0-current-20261101 in OpenBSD 8.0-current (2026-11-01). Parsed by carta from the page's mdoc source.