Before using a relative filename in a Linux shell, it helps to know which directory the shell is working in. The pwd command prints the path of that directory.
This article shows how to use pwd to check the current directory and choose whether to read its logical or physical path.
TL;DR
The pwd command prints the path of the directory your shell is currently working in.
- Run pwd to print the current path.
- Use pwd -L for the logical path held by the shell.
- Use pwd -P to ask for the physical path.
What Does the pwd Command Show?
The name expands to “print working directory,” and the result is an absolute path from the filesystem root. For example, /home/lee/projects starts at / and ends at the projects directory. A relative path omits the leading slash and is resolved from the current directory.
Relative paths omit the leading slash and are resolved from the current directory. The final name in /home/lee/projects is projects, while .. refers to its parent.
The cd command changes location. For link behavior, see this Linux symbolic-link guide.
How to Use pwd and Read Its Output
I ran the command from /home/ubuntu and got /home/ubuntu as output.
Step 1: Print the current directory
At a shell prompt, enter the command below. A leading slash marks the result as an absolute path, which can be used from any working directory.
pwd
/home/ubuntu

Because the output starts with a slash, it is an absolute path. This compact check shows the directory without adding shell setup.
Step 2: Choose a logical or physical path
A symbolic link can give one directory two names. GNU pwd documents its logical and physical path options.
pwd -L
pwd -P
Step 3: Check which pwd implementation runs
I ran type pwd and /bin/pwd -P. The output identifies the shell built-in and prints the external utility result.
type pwd && /bin/pwd -P
The paired check shows shell resolution alongside the standalone utility output.

When Can pwd Show a Different Path?
The GNU Coreutils manual documents the standalone utility, while Bash also provides pwd as a built-in. In Bash, PWD stores the logical path and is updated as the shell changes directories.
- For the shell’s logical path, inspect PWD with printf ‘%s\n’ “$PWD”.
- For the external utility’s physical path, run /bin/pwd -P.
- To identify shell resolution, run type pwd.
A shell script can read that variable when it needs the path Bash tracks, for example with printf ‘%s\n’ “$PWD”. Use /bin/pwd -P when the task calls for the filesystem path with symbolic links resolved.
Read the GNU Coreutils pwd manual for the standalone utility and the Bash builtins reference for shell behavior.
Common pwd Path Issues
Unexpected output calls for checking path style. In Bash, PWD is a variable separate from the pwd command, and it changes when the shell changes directories. A script that reads PWD gets the shell’s stored value.| Symptom | Check | Next step |
|---|---|---|
| Link name appears in the path | Compare logical and physical output | Run pwd -L and pwd -P |
| Shell and external output differ | Check command resolution | Run type pwd |
| A script needs the shell’s stored path | Read PWD | Run printf ‘%s\n’ “$PWD” |
The command syntax is pwd [OPTION]… . With no option, the shell or utility uses its default behavior.
GNU pwd accepts -L to report the logical name and -P to resolve symbolic links. Choose the flag that matches whether you want the path name or resolved filesystem location.
The PWD environment variable is useful inside shell scripts that need the directory associated with the current shell. You can inspect it with printf ‘%s\n’ “$PWD”. A child process receives environment variables exported by its parent, but the value belongs to that process environment, so scripts should use a path check suited to their shell and workflow.
Reviewer note: GNU Coreutils provides a standalone pwd utility, and Bash documents pwd as a built-in. That distinction matters when comparing behavior: type pwd shows which command Bash resolves, while /bin/pwd explicitly selects the external utility. Choose the explicit form when you need to compare the shell’s command with the installed program.
The pwd command is available on common Unix-like systems, including Linux and macOS, though exact options and shell behavior can vary. These commands focus on GNU/Linux. On another operating system, check its local pwd manual page before relying on GNU-specific details.
The table separates path-name differences from command-resolution issues. For a script, check PWD only when you specifically need Bash’s tracked logical value. For filesystem inspection, compare pwd -P.
Conclusion: Check the Directory Before Using a Relative Path
Before using a relative filename, check which directory the shell will use. The Linux cd guide explains how to change it. A quick pwd check can prevent a command from targeting an unintended location.
FAQ
These answers cover common questions about the pwd command in Linux.
What does pwd mean in Linux?
pwd stands for print working directory. It prints the path of the directory the shell is currently using.
What is the purpose of the pwd command?
Use pwd to see the current working directory, especially before using a relative path in a command or script.
What is the difference between pwd -L and pwd -P?
-L reports the logical path, which can retain symbolic links. -P resolves symbolic links and reports the physical path.
