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

NameTypeDescription
directorypathDestination directory; defaults to HOME.
-LoptionUse logical path handling.
-PoptionUse physical path handling.

Return Value

exit status

0 if directory change succeeds; nonzero otherwise.

Working Example

Example Snippetbash
cd .
Bash Reference