PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchpwd prints the current working directory; it does not change it. Use pwd -L to request a logical path that may retain symbolic-link names, or pwd -P to request the physical, symlink-resolved path. Which implementation runs—a shell builtin or an external utility—can affect defaults, so explicit options are useful when the distinction matters.
Choose the path format you need
A logical path reflects the route represented by the shell’s current-directory state and can preserve a symbolic-link name. A physical path resolves symbolic links to the directory’s actual path components.
As an Amazon Associate I earn from qualifying purchases.
- Use
-Lwhen the symlinked route is meaningful to your workflow or to the person reading the output. - Use
-Pwhen you need the resolved filesystem path.
GNU pwd uses a valid absolute PWD value for logical output when that value contains no . or .. components. If it is unsuitable, GNU falls back to physical handling. GNU’s default is physical unless POSIXLY_CORRECT is set. Bash documents its builtin’s default as physical unless set -o physical is enabled. When both -L and -P are supplied to GNU pwd, the last option wins. See the GNU Coreutils pwd documentation and the Bash builtin reference.
15 practical pwd examples
Run these in a shell. Examples that change directories affect the current shell session; run them separately if you do not want one example’s location to affect the next.
#1 Best Overall
-
Print the current directory
pwdPrints the current working directory using the behavior of the command implementation that runs.
-
Request a logical path
pwd -LAsks for the logical path, which can retain symbolic-link names.
-
Request a physical path
pwd -PAsks for the path with symbolic links resolved.
-
Use GNU’s long option for logical output
pwd --logical -
Use GNU’s long option for physical output
pwd --physical -
Put physical mode last
pwd -L -PFor GNU
pwd, the final mode option determines the requested mode, so this asks for physical output.The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Put logical mode last
pwd -P -LFor GNU
pwd, this asks for logical output. -
Change to
/tmp, then print the locationcd /tmp pwdThe first command changes the shell’s current directory; the second prints it.
-
Move to the parent directory
cd .. pwdcd ..moves to the parent of the current directory, andpwdprints the resulting location. -
Go to your home directory
cd ~ pwdThe shell expands
~to your home directory before changing location.Rank #4
-
Invoke Bash’s builtin explicitly in physical mode
builtin pwd -PIn Bash,
builtinselects the shell builtin rather than an external command.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Invoke Bash’s builtin explicitly in logical mode
builtin pwd -L -
Run the external utility through
envenv pwd -PGNU documents this form as a way to avoid shell aliases and builtin functions when invoking the external utility.
-
Save the output in a variable
current_dir=$(pwd) printf '%sn' "$current_dir"Command substitution captures the printed path for later use. Quoting the variable keeps its value together if the path contains spaces.
-
Check whether printing the directory succeeds
if pwd >/dev/null; then printf '%sn' 'Current directory is available' fipwdreturns status zero on success and nonzero on failure; the conditional runs its body only when the command succeeds.
Know which pwd implementation is running
pwd may resolve to a shell builtin or an external utility. Bash includes a pwd builtin. GNU notes that an unqualified invocation can be affected by shell aliases or functions; in GNU environments, env pwd ... invokes the external utility instead. Use builtin pwd ... in Bash when you specifically want its builtin, or env pwd ... when you want to bypass shell aliases and functions for the external command. Explicitly choosing -L or -P makes your intended path style clearer, but defaults and supported options still depend on the implementation.
GNU’s documented options and behavior are in its pwd invocation reference; Bash’s builtin behavior is described in its Bourne Shell Builtins reference.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




