pwd command (Linux / bash / sh / zsh)
What it does
Print the absolute path of the current working directory. When people search for the pwd linux current directory, they usually want pwd's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Print the absolute path of the current working directory.
Syntax
pwd [OPTION]
Common options
| Flag / option | Meaning |
|---|---|
| -L | Show the logical path, preserving symbolic links. |
| -P | Resolve symbolic links to the physical path. |
| --help | Display usage help. |
Practical examples
Show location
pwd
Prints the current logical path.
Resolve links
pwd -P
Prints the physical directory path.
Capture path
project_dir=$(pwd)
Stores the current path in a shell variable.
Linux ↔ Windows equivalent
Closest match: cd (Windows / CMD). Display or change the current directory in Command Prompt.
In CMD, cd with no argument prints the current path.
Common mistakes
- Assuming logical and physical paths are identical when symlinks are involved.
- Using unquoted command substitution when the resulting path may contain spaces.
Related commands
- cdChange the shell's current working directory.
- lsList directory entries and inspect file metadata.
- whichLocate the executable selected from the current PATH.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- cdDisplay or change the current directory in Command Prompt.
- rmRemove files and directory trees permanently.
FAQ
What does pwd do in Linux?
Print the absolute path of the current working directory.
How do I use pwd from the terminal?
Start with `pwd [OPTION]`, then choose only the options needed for the task.
What is a practical pwd example?
Try `pwd` — Prints the current logical path.
Can I use pwd in a shell script?
Yes. pwd works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.