cd

Change the current working directory.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

cd updates the shell's working directory. `cd -` returns to the previous directory. `cd ~` always goes home. In scripts, always pair cd with `|| exit 1` to catch failure before running destructive follow-up commands.

Examples
cd /var/log/nginxNavigate to nginx log directory · explain & risk-check →
cd -Jump back to the previous directory · explain & risk-check →
cd ~Go to your home directory from anywhere · explain & risk-check →
Pro tip

Use `pushd /path` and `popd` when you need a directory stack — navigate away and return without remembering the original path.

Related
pwd pushd popd ls
Open the full explainer →More in Files & Archives

Reference text is hand-written and may be incomplete — check man cd for your version. Test destructive commands on a non-production system first.