The pwd command in Linux
pwd stands for "print working directory" and does exactly one thing: it prints the absolute path of the directory your shell is currently in. It sounds trivial, but it is the fastest way to orient yourself, and it matters in scripts, where knowing the current directory prevents files being created in the wrong place.
How pwd works
The kernel tracks each process's working directory as a reference to the directory itself, not as a text path. pwd's job is reconstructing the human-readable path — walking up parent by parent, or, in the common case, just printing the $PWD variable the shell maintains as you cd around.
That dual bookkeeping is where -L and -P come from. The shell's $PWD remembers the route you took, symlinks included (the logical path); asking the kernel and resolving every component yields the physical one. When a build tool and your prompt disagree about "where you are", you are standing inside a symlinked directory and seeing the two answers side by side.
Syntax
pwd Common options
| Option | What it does |
|---|---|
-P | Print the physical path, resolving any symbolic links. |
-L | Print the logical path, keeping symlinks as you traversed them (default). |
How to use pwd: examples
$ pwd Prints something like /home/user/documents — the full path from the filesystem root.
$ echo "You are in: $(pwd)" Command substitution: use the output of pwd inside another command or script.
Real-world use cases for pwd
Confirming where a script runs
Cron jobs run from unexpected working directories (usually the user's home). Logging "$(pwd)" as the first line of a cron script is the fastest way to explain why its relative paths behave differently than in your terminal.
Copying the current path
You need to reference your current location in another terminal, a config file, or a message to a colleague. pwd prints the canonical absolute path, ready to copy — no reconstructing it from the prompt.
Try pwd yourself
This is a live sandbox with a small filesystem (documents/, notes.txt,
backup.sh…). Nothing you do here can break anything — experiment freely.
Try: pwd
Pro tips and common mistakes
- Inside a symlinked directory, pwd shows the logical path; pwd -P reveals the physical one. When two tools disagree about "where" a file is, this is usually why.
- In scripts, prefer "$PWD" (the variable) over calling pwd — same value, no subprocess.
- Command substitution turns pwd into a building block: tar -czf "backup-$(basename $(pwd)).tar.gz" . names the archive after the current directory.
Frequently asked questions about pwd
What does pwd stand for?
Print Working Directory. It prints the absolute path of the shell's current directory.
Is the prompt not enough to know where I am?
Many prompts show only the last folder name or abbreviate the path. pwd always prints the complete, unambiguous absolute path.
Related commands
List the contents of a directory, with options for hidden files, long format, sorting and more.
cdMove between directories: absolute and relative paths, home shortcut, and jumping back.