You really are in
/home/cpm135/public_html/class -- that's the only correct answer to the question of "what's my current working directory".
When you refer to
/var/lib/class ... that's not really about where you are, but more about what path you used to get there.
When you run
/bin/pwd, it figures out your current working directory by looking at the . and .. directories (the ones listed at the top of
ls -la), working out which directory in .. matches up with . and then working backwards until .. and . refer to the same directory. Once it's done all that, it knows what your current working directory is.
When you run the
pwd shell built-in, it doesn't follow this procedure (though it might do some of it if needed) -- instead, it remembers the path that you took to get here. So each time you do a
cd command, your shell remembers that as part of the path to get where you are now, and
pwd prints out what it has calculated based on all the
cd commands you've done -- which may or may not be your actual working directory.
Things can get really weird when you do a
ln -s . foo and keep
cding into foo --
/bin/pwd will say you're still in the same directory, but the shell builtin
pwd will say you're in
/foo/foo/foo/foo/foo/foo -- even though no such directory even really exists. (That said -- you probably can
cd into it.)
Another source of confusion there is if directories are renamed.
/bin/pwd will then pick up on the change immediately, but the built-in
pwd won't until you do something that tells it that the old directory name doesn't matter.
fishshell automatically resolves the symlink when you