cd
going somewhere elsecd moves the shell to another directory. It takes an absolute path, which starts at the root, or a relative one, which starts from where you are. It prints nothing when it works — silence is success, as with most Unix commands.
A path that begins with a slash means the same thing everywhere. One that does not depends on where you are standing.
At the terminal
Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.
What the numbered lines are telling you
/var/log begins at the root, so it names the same directory no matter where the shell was.
No leading slash: "nginx" is looked for inside the current directory, giving /var/log/nginx.
Every directory contains an entry called ".." that points one level up. This returns to /var/log.
cd - swaps back to the previous directory and prints it, so you can flip between two places.
cd with no argument goes to your home directory. The tilde, ~, is shorthand for the same place.
Switches
A switch changes how the command behaves. These are the ones used day to day; man cd lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.
-- Go back to the directory you were in before the last cd.
..- Go up one level, to the parent directory.
~- Go to your home directory. Plain cd does the same.
-P- Follow the physical path: resolve symbolic links instead of keeping them in the path.
Variations worth knowing
The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.
cd ~/projectsThe tilde expands to your home directory, so this works from anywhere.
cd ../..Up two levels in one step.
cd "My Documents"Quote a name that contains spaces, or the shell reads it as two arguments.
pushd /etc && popdRemembers where you were on a stack and returns to it — handy when hopping between several places.
In cybersecurity
To enter a directory you need the execute bit on it, not the read bit — a detail that explains most "Permission denied" answers from cd.
Without it nobody can cd in or reach anything beneath, whatever the files' own permissions say.
In a script, "cd build; rm -rf *" deletes the wrong directory if cd failed. Write "cd build && …" or stop on error.
The same ".." that takes you up a level is how a careless web application is talked into reading files outside its folder.