READLINK(1B) BSD System Compatibility READLINK(1B)

readlink - (BSD) displays the target of a symbolic link

readlink [-fn] file

The readlink utility, when called with the path of a symbolic link as its argument, displays the real path/target of it at the standard output.

It accepts the following options:

Follows the symbolic link until it reaches the original target, recursively.
Does not print a newline character at the end of the output string.

If readlink is invoked without the -f option and with other argument than the path of a symbolic link, it will exit with a non-zero exit code without anything being printed.

The readlink utility may be used at shell scripts for displaying/modifying the real file behind a symbolic link. For instance, it can be used to find the real program behind a process on the /proc directory — via the proc(5) file system.

readlink -f /proc/$$/exe

ln(1), ls(1), file(1), readlink(2), realpath(3)

The readlink utility first appeared in OpenBSD 2.1, NetBSD 1.6 and FreeBSD 4.10.

02/23/23 Heirloom Toolchest