| Use Case | Command | Description |
|---|---|---|
| ๐ Read symlink target | readlink /path/to/symlink |
Outputs the value of the symbolic link (default mode) |
| ๐งญ Resolve to canonical absolute path | readlink -f /path/to/file |
Outputs the absolute path with no ., .., or symlinks |
| โ Resolve existing path | readlink -e /path/to/file |
Canonicalize, require all components to exist |
| ๐ฎ Resolve even missing components | readlink -m /path/to/missing |
Canonicalize, treat missing components as directories |
| ๐ Suppress errors | readlink -q /path |
Quiet mode (on by default) |
| ๐ Output NUL-separated | readlink -z /path |
Use NUL byte instead of newline (safe for embedded newlines) |
readlink may work in one of two supported modes:
readlink outputs the value of the given symbolic links. If invoked with an argument other than the name of a symbolic link, it produces no output and exits with a nonzero exit code.
readlink outputs the absolute name of the given files which contain no ., .. components nor any repeated separators (/) or symbolic links. Note the realpath command is the preferred command to use for canonicalization. See realpath invocation.
Usage: readlink [OPTION]... FILE...
By default, readlink operates in readlink mode.
The program accepts the following options. Also see Common options.
-f, --canonicalize โ ๐งญ Activate canonicalize mode. If any component of the file name except the last one is missing or unavailable, readlink produces no output and exits with a nonzero exit code. A trailing slash is ignored.-e, --canonicalize-existing โ โ
Activate canonicalize mode. If any component is missing or unavailable, readlink produces no output and exits with a nonzero exit code. A trailing slash requires that the name resolve to a directory.-m, --canonicalize-missing โ ๐ฎ Activate canonicalize mode. If any component is missing or unavailable, readlink treats it as a directory.-n, --no-newline โ ๐ซ Do not print the output delimiter, when a single FILE is specified. Print a warning if specified along with multiple FILEs.-s, -q, --silent, --quiet โ ๐ Suppress most error messages. On by default.-v, --verbose โ ๐ข Report error messages.-z, --zero โ ๐งต Output a zero byte (ASCII NUL) at the end of each line, rather than a newline. This option enables other programs to parse the output even when that output would contain data with embedded newlines.The readlink utility first appeared in OpenBSD 2.1.
The realpath command without options, operates like readlink in canonicalize mode.
An exit status of 0 indicates success, and a nonzero value indicates failure.
Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-31 03:52 @216.73.217.152
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format