On this page
pwd
pwd — "print working directory" — prints the absolute path of the directory you are currently in.
pwd [options]
$ pwd
/home/jack/projects
Every process has a working directory: the directory that relative path names are interpreted against. pwd tells you what yours is.
Physical and logical paths
There are two honest answers to "where am I", and they differ only when symbolic links are involved.
Suppose /home/jack/work is a symbolic link pointing at /data/projects/jack, and you move into it. The physical path — the real location, with every link resolved — is /data/projects/jack. The logical path — the route you took to get there — is /home/jack/work.
| Option | Path printed |
|---|---|
-P, --physical |
The physical path: every symbolic link resolved to its target. |
-L, --logical |
The logical path: the route recorded as you navigated, taken from the PWD environment variable when it is accurate. |
By default pwd prints the physical path — -P is the default, and naming it explicitly just makes that choice visible. Use -L when you want the path as you navigated it, links and all.
If -L is requested but the recorded PWD value is missing or does not actually match the current directory, pwd falls back to the physical path rather than print something wrong.
A note on shells
Many command shells provide their own built-in pwd, and the shell's version is what runs when you type pwd at a prompt. The two behave the same for everyday use. To be certain you are running this command rather than the shell built-in, invoke it by its full path.
Exit status
| Code | Meaning |
|---|---|
0 |
The working directory was printed. |
1 |
The working directory could not be determined or could not be printed. |