It’s the simple things in life… Sometimes you simply want to know the canonical path for your current working directory.

Here is a symbolic link to a directory.

$ ls -go /home/crashingdaily/symlink
lrwxrwxrwx 1 14 Mar 29 10:54 /home/crashingdaily/symlink -> im/a/real/path

I change to the directory using the symbolic link.

$ cd /home/crashingdaily/symlink

The ‘pwd’ bash builtin does not resolve symbolic links so reports that I’m in the ‘symlink’ directory.

$ pwd

‘/bin/pwd’ reports the canonical path.

$ /bin/pwd

I can leverage this to quickly change my path from symlinked to real.

$ pwd

$ cd `/bin/pwd`

$ pwd

Also see

readlink -f .

readlink is advantageous if you need to resolve paths outside your current working directory.

Update: Sometimes the simpler things are right under your nose.

pwd -P


cd -P .

were sitting there all along. No need for /bin/pwd (for bash at least). RTFM, indeed.