pwd Print the current working directory
Prints the full path of the folder you are in. Use it when you are lost in a terminal, or when a script needs to record where it is running. The path starts at the root, /, and has no shortcuts.
Synopsis
pwd [-L | -P]
Common options
| Option or form | What it does |
|---|---|
-L | Logical path. Keeps symbolic link names as you typed them. This is the default |
-P | Physical path. Resolves every symbolic link to the real folder |
(no option) | Behaves like -L |
$PWD | A shell variable that holds the same logical path, kept up to date by cd |
$OLDPWD | A shell variable that holds the previous directory, the one cd - returns to |
/bin/pwd | The separate program version. It accepts -L and -P like the builtin and defaults to -L as well |
Examples
pwd
pwd -P
cd docs/old && pwd
here=$(pwd) && echo "running in $here" > /dev/null
pwd -L && pwd -P
/bin/pwd
Notes
- In most shells pwd is a builtin, and a separate /bin/pwd program also exists. Both default to the logical path, so they normally agree. Use the builtin in everyday work and in scripts.
- The two paths differ only when you reached the folder through a symbolic link. In a folder with no links in its path, pwd -L and pwd -P print the same thing.
- On macOS, /tmp, /var and /etc are links into /private. After cd /tmp, pwd -L prints /tmp and pwd -P prints /private/tmp.
- To store the current folder, use $(pwd) or the $PWD variable. Put quotes around it when you use it, because the path can contain spaces.
- pwd only reads information and changes nothing, so it is safe to run at any time.
See also
Last reviewed 2026-10-07.