For most commands we invoke on the command line, the current working directory is an important element of the runtime context. For example, if we invoke a command that modifies a specified file, the file in question is often specified with a path that is assumed to be relative to the working directory. Even the command we invoke is sometimes specified using a path relative to the working directory.

Usually, the shell automatically gives us some information about the working directory; for example, the name of the directory might be displayed as part of the prompt where commands are typed. However, this might not include the full path to that directory; that additional information is often essential.

Commands

To display the full path of the working directory, use the appropriate command below:

Windows Command Prompt

cd

Bash shell (OS X & Ubuntu Terminal, Git Bash, etc.)

pwd

Tasks

In your command-line (shell) program, invoke the appropriate command to display the working directory. Note that the value displayed is the entire path, from the root of the file system to the working directory.