xref: /freebsd/bin/pwd/pwd.1 (revision edf8578117e8844e02c0121147f45e4609b30680)
1.\"-
2.\" Copyright (c) 1990, 1993
3.\"	The Regents of the University of California.  All rights reserved.
4.\"
5.\" This code is derived from software contributed to Berkeley by
6.\" the Institute of Electrical and Electronics Engineers, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)pwd.1	8.2 (Berkeley) 4/28/95
33.\"
34.Dd May 22, 2023
35.Dt PWD 1
36.Os
37.Sh NAME
38.Nm pwd
39.Nd return working directory name
40.Sh SYNOPSIS
41.Nm
42.Op Fl L | P
43.Sh DESCRIPTION
44The
45.Nm
46utility writes the absolute pathname of the current working directory to
47the standard output.
48.Pp
49Some shells may provide a builtin
50.Nm
51command which is similar or identical to this utility.
52Consult the
53.Xr builtin 1
54manual page.
55.Pp
56The options are as follows:
57.Bl -tag -width indent
58.It Fl L
59Display the logical current working directory.
60.It Fl P
61Display the physical current working directory (all symbolic links resolved).
62.El
63.Pp
64If no options are specified, the
65.Fl P
66option is assumed.
67.Sh ENVIRONMENT
68Environment variables used by
69.Nm :
70.Bl -tag -width ".Ev PWD"
71.It Ev PWD
72Logical current working directory.
73.El
74.Sh EXIT STATUS
75.Ex -std
76.Sh EXAMPLES
77Show current working directory with symbolic links resolved:
78.Bd -literal -offset indent
79$ /bin/pwd
80/usr/src/sys/kern
81.Ed
82.Pp
83Show the logical current directory.
84Then use
85.Xr file 1
86to inspect the
87.Pa /sys
88directory:
89.Bd -literal -offset indent
90$ /bin/pwd -L
91/sys/kern
92$ file /sys
93/sys: symbolic link to usr/src/sys
94.Ed
95.Sh SEE ALSO
96.Xr builtin 1 ,
97.Xr cd 1 ,
98.Xr csh 1 ,
99.Xr realpath 1 ,
100.Xr sh 1 ,
101.Xr getcwd 3
102.Sh STANDARDS
103The
104.Nm
105utility conforms to
106.St -p1003.1-2001 .
107.Sh HISTORY
108The
109.Nm
110command appeared in
111.At v5 .
112.Sh BUGS
113In
114.Xr csh 1
115the command
116.Ic dirs
117is always faster because it is built into that shell.
118However, it can give a different answer in the rare case
119that the current directory or a containing directory was moved after
120the shell descended into it.
121.Pp
122The
123.Fl L
124option does not work unless the
125.Ev PWD
126environment variable is exported by the shell.
127