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.
lsIncorrect. ls lists directory contents.
pwdCorrect. pwd prints the current working directory.
echo PATHIncorrect. 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 / 一時ディレクトリ
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
pwd reports the shell's current directory; its logical and physical forms can differ after link traversal.
Check the side effect
Use pwd -L and pwd -P when a symlinked path needs to be distinguished from its resolved path.