READLINK(1) General Commands Manual READLINK(1)

readlinkdisplay target of a symbolic link

readlink [-fnqsv] file ...

The readlink utility displays the target of a symbolic link. If a given argument file is not a symbolic link and the -f option is not specified, readlink will print nothing to standard output about that file and eventually exit with an error status. If the -f option is specified, the output is canonicalized by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths, and, if possible, return the absolute pathname corresponding to file. In this case, the argument does not need to be a symbolic link.

The options are as follows:

Canonicalize the pathname of file, as described above.
Do not force a newline to appear after the output for each file.
Suppress failure messages if calls to lstat(2) fail. This is the default for readlink.
This is an alternative to -q.
Turn off quiet mode. readlink will display errors about files for which lstat(2) fails, or without -f, which are not symbolic links. This is the inverse of -q and -s.

To obtain standards compliance, if POSIXLY_CORRECT is set in the environment, then -v is the default, rather than -q.

readlink will exit with status 1 on a usage error, or if any of the given file arguments do not exist, or if -f is absent and any file arguments do not name symbolic links. Otherwise readlink exits with status 0.

realpath(1), stat(1), lstat(2), readlink(2)

readlink is expected to conform to IEEE Std 1003.1-2024 (“POSIX.1”), provided it is run with POSIXLY_CORRECT set in its environment.

The readlink utility appeared along with stat, within which it is integrated, in NetBSD 1.6.

The stat utility was written by Andrew Brown ⟨atatat@NetBSD.org⟩. The original combined man page was written by Jan Schaumann ⟨jschauma@NetBSD.org⟩.

May 3, 2025 NetBSD 10.99