Display the shell's current working directory as an absolute path.
Which command should be used?
pwd, short for print working directory, prints the current working directory as an absolute path.
Detailed explanation
cdIncorrect. cd changes directories and does not print the current path as its main purpose.
Incorrect. cd changes directories and does not print the current path as its main purpose.
lsIncorrect. ls lists directory contents.
Incorrect. ls lists directory contents.
pwdCorrect. pwd prints the current working directory.
Correct. pwd prints the current working directory.
echo PATHIncorrect. echo PATH prints a literal word here and does not inspect the current directory.
Incorrect. echo PATH prints a literal word here and does not inspect the current directory.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); (cd "$tmp" && pwd); rmdir "$tmp"Expected result
作成した一時ディレクトリの絶対パスKey points
- pwd prints the current directory
- The output is an absolute path
- cd changes location
Notes
- Environment: Bash 5.x / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.