Home

pwD

PWD is an acronym commonly used in Unix-like environments to denote the present working directory. It can refer to two related concepts: the environment variable named PWD that stores a path, and the pwd command (or shell builtin) that prints the current directory.

The PWD environment variable is maintained by the shell and is updated as the user changes directories

The pwd command prints the current working directory. In GNU coreutils, it supports -L and -P: -L

Logical versus physical: The logical path reflects the path as seen by the user (including symbolic links)

Related concepts include OLDPWD, which stores the previous directory, and HOME, the user's home directory. PWD

with
the
cd
command.
It
generally
contains
the
absolute
path
of
the
current
directory
and
is
inherited
by
child
processes.
However,
if
the
directory
is
changed
outside
the
shell,
the
variable
can
become
stale.
For
robust
scripts,
rely
on
a
command
such
as
pwd
to
determine
the
current
directory,
and
be
aware
of
the
-L
versus
-P
options
when
applicable.
prints
the
logical
path,
i.e.,
the
path
as
stored
in
PWD,
including
symbolic
links
as
they
appear
to
the
user;
-P
prints
the
physical
path,
resolving
all
symbolic
links
to
their
real
locations.
The
default
is
typically
-L.
In
many
shells,
pwd
is
also
a
builtin
with
similar
options.
if
the
shell
tracks
PWD;
the
physical
path
reflects
the
actual
directory
on
disk
with
all
symlinks
resolved.
For
example,
if
/home/user/links/dir
is
a
symlink
to
/mnt/data/real,
cd
/home/user/links/dir
and
run
pwd
-L
might
yield
/home/user/links/dir,
while
pwd
-P
would
yield
/mnt/data/real.
behavior
can
vary
between
shells
and
environments,
so
understanding
the
distinction
between
the
environment
variable
and
the
pwd
command
helps
in
scripting
and
navigation.