Linux pwd command

Updated: 03/13/2021 by Computer Hope
pwd command

On Unix-like operating systems, the pwd command outputs the name of the working directory.

This page covers the GNU/Linux version of pwd.

Description

The default behavior of pwd is slightly different depending on if you are running the stand-alone command, or the built-in pwd command that is included in your shell. If you are using the bash shell, you can determine which pwd is the default with the type command:

type pwd
pwd is a shell built-in

To specify that you want to run the stand-alone program instead of the shell built-in, use its complete path in the command:

/bin/pwd

This page describes the GNU/Linux stand-alone version of pwd.

Syntax

pwd [OPTION]...

Options

-L, --logical If the environment variable PWD contains an absolute name of the current directory with no "." or ".." components, then output those contents, even if they contain symbolic links. Otherwise, fall back to default (-P) behavior.
-P, --physical Print a fully resolved name for the current directory, where all components of the name are actual directory names, and not symbolic links.
--help Display a help message, and exit.
--version Display version information, and exit.

Examples

pwd

Print the name of the working directory. If any of the subdirectories in the path are symbolic links, and you used the symlink names when changing to the directory, the symlink names are printed. Example output:

/home/hope/mysymlink/mydir
pwd -P

Print the name of the working directory, using the actual names of the directory components, even if their symlink names were used when changing to the directory. Example output:

/home/hope/actual_directory_name/actual_subdirectory/mydir

cd — Change the working directory.
readlink — Print the value of a symbolic link or canonical file name.