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