Skip to main content

Command referencepwd

pwd command (Linux / bash / sh / zsh)

Linuxbashshzshfilebeginner

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 / optionMeaning
-LShow the logical path, preserving symbolic links.
-PResolve symbolic links to the physical path.
--helpDisplay 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.

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.