commands

cd — change working directory

Bash builtin changes the working directory of the current shell; no directory uses HOME. Logical and physical navigation differ around symlinks. On failure, inspect the error and pwd before changing files. Examples assume a fresh chapter files lab.

Formal Syntax & Structure

linux syntaxlinux
cd [DIRECTORY]

Parameters & Attributes

NameTypeDescription
-PoptionUse physical directory resolution
DIRECTORYoperandDestination path; defaults to HOME

Return Value

directory change and exit status

Bash returns 0 when the directory change succeeds and nonzero when it fails. Inspect pwd to confirm the new working directory; stdout is normally empty except in cases such as CDPATH or cd -.

Working Example

Example Snippetlinux
cd notespwd
Linux Reference