The working directory belongs to the process
The kernel stores a current working directory for every process. When a program opens a relative path, the kernel resolves that path starting from this directory. The value is not a string kept by the program. It is a reference to an inode, and it stays valid even if the directory is later renamed or moved. If the directory is removed while a process sits in it, the process keeps the reference, and its relative paths continue to work until it asks for a path that goes outside the removed directory.
When you start a command, the child process inherits the working directory of the shell that launched it. Bash then passes its own environment to the child, and the child starts in the same place. Nothing that the child does with cd can affect the parent, because changing the directory is an action on the process itself. This is the reason a program cannot change your shell's directory for you. The shell has to make the change, and cd is a builtin for exactly that reason.
cd /workspace
bash -c 'cd /etc && pwd'
pwdThe inner bash changes to /etc and prints it. The outer shell still prints /workspace, because the inner shell changed only its own working directory. If you want a change that persists, you must run cd in the shell you are using, or source the script.
pwd and its two answers
The command pwd prints the working directory, but it can answer in two ways. By default, the bash builtin prints the logical path, which is the path as the shell understood it, including any symbolic links you passed through. The option -P prints the physical path, which is the real location after all links are resolved. The external program /bin/pwd behaves the same way with the same options. The logical path is stored in the variable PWD, and the physical path is what the kernel actually knows.
The difference is visible only when a link is involved. Create a link and move into it, then ask for both views. The logical view keeps the name you typed, which is usually what you want for prompts and for reading a path back. The physical view tells you where the files really are, which matters for backups, for comparing directories, and for any tool that must avoid following links.
cd /workspace
ln -sfn /etc shortcut
cd shortcut
pwd
pwd -PThe first pwd prints /workspace/shortcut. The second prints /etc. Both are correct answers to different questions.
cd and its options
With no argument, cd moves to $HOME. With a hyphen, it moves to $OLDPWD and prints the new location. Bash's cd accepts -L and -P. The default is -L, which keeps the logical path. The option -P asks for the physical location, which means that .. is then resolved against the real directory rather than against the text. If you are in a logical directory reached through a link and you use cd .., the shell may take you back up the name you typed, while cd -P .. takes you to the physical parent.
The variable CDPATH is a colon-separated list of directories that bash searches when a relative name does not start with ./ or /. It is convenient for jumping to a project from anywhere, but it also changes what a short name means, so scripts usually leave it unset. If bash uses a directory found through CDPATH, it prints the directory it changed to, which makes the effect visible.
Do not write cd dir && rm -rf * without checking that the directory change succeeded. If cd fails and the shell continues, the removal runs in the wrong directory. Write cd dir || exit 1 in scripts, so that a failed move stops the script.
Subshells keep a directory change contained
Parentheses start a subshell, which is a copy of the shell with its own working directory. A cd inside parentheses changes only the copy, so the directory of the outer shell is unchanged when the group ends. This is a clean way to run a few commands in another directory without the need to remember where you came from. A typical use is (cd build && make), where the make command runs inside the build directory and your prompt stays where it was.
Braces group commands without starting a subshell, so a cd inside braces changes the current shell. Choosing between the two is a common source of bugs. If you want the change to persist, use braces or no grouping at all. If you want it to disappear, use parentheses. Both forms return the exit status of the last command, which lets you chain them with || to stop on failure.
The same idea applies to pushd and popd, which keep a stack of directories that you can return to. They are convenient at a prompt, but a script is easier to read when it uses subshells and absolute paths, because a reader can see the directory of every command without tracing a stack.
Why scripts should avoid relying on the current directory
A script that uses relative paths works only from the directory where its author ran it. A common pattern is to find the directory of the script and move there first. The idiom cd "$(dirname "$0")" does that, although it has edge cases with symbolic links. An even safer habit is to build absolute paths from a variable that you set once, so every line of the script names its files without depending on where the script was started.
Practice in the lab
Use the lab to change directories, record where you are, and confirm the difference between the logical and physical views. Each lab step writes its result into a file in /workspace, because the checker cannot see the state of your shell. The shell state disappears when the step ends, so the file is the evidence that counts.