DELAPARRA
Index
Color
NL
Category: CLI commands

cd

Explained by Updated

What is cd?

cd: Change Directory — Navigate to a different directory. cd changes the current folder in a terminal. cd projects/shop moves into that folder, cd .. goes up one level, cd ~ or just cd goes to your home folder, and cd - jumps back to the previous one. Every command you run uses the current folder as its starting point. Relative paths, Git commands and project scripts all depend on where you are.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about cd

What should you keep in mind with cd?

In scripts, be careful with cd. If it fails because a folder does not exist, the script carries on in the wrong place, and the next command, such as a delete, runs where you did not intend. Use cd /path || exit 1, or set -e at the top, so the script stops when cd fails. Better still, use absolute paths for anything destructive.

At a glance

CategoryCLI commands
Explained by
Updated

More CLI commands terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.