builtin
Bash cd — change working directory
Changes the working directory of the current shell. A relative path is interpreted with respect to the current directory, subject to CDPATH lookup rules. With no directory, normally uses HOME. -L uses logical path handling; -P uses physical path handling. Use a known existing lab path for practice.
Formal Syntax & Structure
bash syntaxbash
cd [-L|-P] [directory]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| directory | path | Destination directory; defaults to HOME. |
| -L | option | Use logical path handling. |
| -P | option | Use physical path handling. |
Return Value
exit status
0 if directory change succeeds; nonzero otherwise.
Working Example
Example Snippetbash
cd .