READLINK(1) | General Commands Manual | READLINK(1)

# NAME

`readlink` — display target of a symbolic link

# SYNOPSIS

`readlink` | [`-fnqsv`] file ...

# DESCRIPTION

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:

`-f`
  Canonicalize the pathname of file, as described above.
`-n`
  Do not force a newline to appear after the output for each file.
`-q`
  Suppress failure messages if calls to lstat(2) fail. This is the default for `readlink`.
`-s`
  This is an alternative to `-q`.
`-v`
  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`.

# ENVIRONMENT

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

# EXIT STATUS

`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.

# SEE ALSO

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

# STANDARDS

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

# HISTORY

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

# AUTHORS

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 11.99