pwd Command

The pwd command (print working directory) displays the full pathname of the current working directory. It's essential for navigation and understanding your location in the file system.

Syntax

pwd [OPTION]...

Description

The pwd command prints the absolute pathname of the current working directory. This is useful when you need to know exactly where you are in the directory structure.

Key features:

  • Shows full absolute path
  • Works from any directory
  • Handles symbolic links
  • No arguments required for basic usage

Options

Option Description
-L Use logical path (default, includes symbolic links)
-P Use physical path (resolve symbolic links)

Examples

Basic usage

pwd

Output: /home/username/Documents

Logical path (with symbolic links)

pwd -L

Shows the path as it appears (including symbolic links)

Physical path (resolve symbolic links)

pwd -P

Shows the actual physical path (resolving any symbolic links)

Use in scripts

CURRENT_DIR=$(pwd)
echo "Working in: $CURRENT_DIR"

Store current directory in a variable for use in scripts

Common Use Cases

  • Navigation reference: Know where you are before changing directories
  • Script development: Get current directory for relative path operations
  • File operations: Confirm location before file manipulations
  • Debugging: Verify script execution location
  • Documentation: Record current working directory

See also