Check location before file operations
Inspect location and contents separately: they answer different questions.
The Bash builtin prints the logical or physical path of the current directory.
pwd
current path
pwd -L
logical path
pwd -P
physical path
type pwd
command implementation
help pwd
Bash help
pwd prints the shell’s current working directory. This page covers the Bash
builtin selected by a plain pwd invocation in the golden snapshot.
A logical path retains symbolic-link components used to reach the directory. A physical path resolves them. Two different path strings can therefore refer to the same directory. Neither result lists files or necessarily identifies the home directory.
Ordinary Bash defaults to -L, using PWD when it identifies the current
directory. -P requests a physical path. Assigning PWD does not change
directories; cd does that.
The external GNU pwd has its own option set. Its help/version options and defaults
are not part of this builtin reference; an external-command snapshot was not
supplied.
| Option | What it does | Example |
|---|---|---|
-L |
Print the logical path, retaining symbolic-link components when PWD is valid. | pwd -L |
-P |
Print the physical path with symbolic links resolved. | pwd -P |
Nothing found. Try a shorter query.
Inspect location and contents separately: they answer different questions.
Compare both results after entering through an existing symbolic link. Identical results are also normal.
Bash may select a builtin, function, or alias. Identifying it explains differences in supported options.
The snapshot shows this message for pwd --version: the builtin was selected. Read
its help through the shell.
A symbolic link can explain the difference without a different directory being involved. Compare logical and physical results.
If the directory path cannot be recovered, change to an existing directory and check again. This does not restore deleted files.
pwd does not modify files. A stale or unchecked path is not sufficient
justification for deletion: inspect the actual target before changing it. The
directory / is not the root account.
cd — changing directory.
links — symbolic links and their targets.
files-basics — navigation and file operations.
bash — shell builtins.
Found an inaccuracy? Report an error in the article