Determine whether cd resolves as an external file, builtin, alias, or function in the current Bash.
Which command is appropriate?
Bash type reports aliases, keywords, functions, builtins, and external files as the shell resolves them.
Detailed explanation
which cdIncorrect. which mainly searches PATH and may not report a shell builtin correctly.
Incorrect. which mainly searches PATH and may not report a shell builtin correctly.
type cdCorrect. type cd reports how Bash resolves the name.
Correct. type cd reports how Bash resolves the name.
whereis cdIncorrect. whereis searches standard filesystem locations.
Incorrect. whereis searches standard filesystem locations.
locate cdIncorrect. locate searches a filename database.
Incorrect. locate searches a filename database.
Try it yourself
An example you can run in a temporary verification environment.
type cdExpected result
cd is a shell builtin相当の表示Key points
- type reports shell resolution
- cd is a builtin
- which is PATH-oriented
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.