1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
.\" $NetBSD: readlink.1,v 1.7 2025/05/03 21:34:08 kre Exp $
.\"
.\" Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Andrew Brown and Jan Schaumann.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 3, 2025
.Dt READLINK 1
.Os
.Sh NAME
.Nm readlink
.Nd display target of a symbolic link
.Sh SYNOPSIS
.Nm
.Op Fl fnqsv
.Ar
.Sh DESCRIPTION
The
.Nm
utility displays the target of a symbolic link.
If a given argument
.Ar file
is not a symbolic link and the
.Fl f
option is not specified,
.Nm readlink
will print nothing to standard output about that
.Ar file
and eventually exit with an error status.
If the
.Fl f
option is specified, the output is canonicalized by following every symlink
in every component of the given path recursively.
.Nm
will resolve both absolute and relative paths, and, if possible,
return the absolute pathname corresponding to
.Ar file .
In this case, the argument does not need to be a symbolic link.
.Pp
The options are as follows:
.Bl -tag -width Fl
.It Fl f
Canonicalize the pathname of
.Ar file ,
as described above.
.It Fl n
Do not force a newline to appear after the output for each
.Ar file .
.It Fl q
Suppress failure messages if calls to
.Xr lstat 2
fail.
This is the default for
.Nm readlink .
.It Fl s
This is an alternative to
.Fl q .
.It Fl v
Turn off quiet mode.
.Nm
will display errors about
.Ar file\^ Ns s
for which
.Xr lstat 2
fails, or without
.Fl f ,
which are not symbolic links.
This is the inverse of
.Fl q
and
.Fl s .
.El
.Sh ENVIRONMENT
.Bl -tag
.It Ev POSIXLY_CORRECT
To obtain standards compliance, if
.Ev POSIXLY_CORRECT
is set in the environment, then
.Fl v
is the default, rather than
.Fl q .
.El
.Sh EXIT STATUS
.Nm
will exit with status 1 on a usage error,
or if any of the given
.Ar file
arguments do not exist, or if
.Fl f
is absent and any
.Ar file
arguments do not name symbolic links.
Otherwise
.Nm
exits with status 0.
.Sh SEE ALSO
.Xr realpath 1 ,
.Xr stat 1 ,
.Xr lstat 2 ,
.Xr readlink 2
.Sh STANDARDS
.Nm
is expected to conform to
.St -p1003.1-2024 ,
provided it is run with
.Ev POSIXLY_CORRECT
set in its environment.
.Sh HISTORY
The
.Nm
utility appeared along with
.Nm stat ,
within which it is integrated, in
.Nx 1.6 .
.Sh AUTHORS
.An -nosplit
The
.Nm stat
utility was written by
.An Andrew Brown
.Aq atatat@NetBSD.org .
The original combined man page was written by
.An Jan Schaumann
.Aq jschauma@NetBSD.org .
|