cd

The builtin that changes the shell's current working directory.

In more detail

cd .. moves up one level, cd on its own goes to your home directory, and cd - goes back to the previous directory. It fails, and returns a non-zero status, if the directory does not exist or you lack permission, so scripts write cd dir || exit to avoid carrying on in the wrong place.

Examples

cd ~/project
cd -
cd notes || exit 1
cd dora
cd ../cookbook
cd ~/python
python3 hello.py

Related terms

Taught in

References

Certification courses