Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I do the following:

cd /some/path
ln -s /target/path symbolic_name

If then do:

cd /some/path
cd symbolic_name

I get:


and not:


Is there a way to have the shell "fully resolve" a symbolic link (i.e. updating CWD, etc.), as if I had directly done:

cd /target/path


I need to run some programs that seem to be "aware" or "sensitive" about how I get to my target path, and I would like them to think that I arrived to the target path as if had done cd /target/path directly.

share|improve this question
Related to this question. You can do pwd -P or alias pwd='pwd -P' also cd -P to go to the physical path instead of the symlink. – Martín Canaval Feb 3 '13 at 22:25
up vote 13 down vote accepted

Your shell has a builtin pwd, which tries to be "smart". After you did a cd to a symlink the internal pwd fakes the output as if you moved to a real directory.

Pass the -P option to pwd, i.e. run pwd -P. The -P option (for “physical”) tells pwd not to do any symbolic link tracking and display the “real” path to the directory.

Alternatively, there should also be a real binary pwd, which does not do (and is even not able to do) this kind of magic. Just use that binary explicity:

$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
$ mkdir a
$ ln -s a b
$ cd b
$ pwd
$ /bin/pwd
share|improve this answer

Try cd -P <symlink_dirname>.

tim@ls:~$ mkdir a
tim@ls:~$ ln -s a b

tim@ls:~$ cd b
tim@ls:~/b$ pwd

tim@ls:~/b$ cd ..
tim@ls:~$ cd -P b
tim@ls:~/a$ pwd

You can also use set -o physical to make this behavior persist through the lifetime of the running shell.

Check out http://stackoverflow.com/questions/10456784/behavior-of-cd-bash-on-symbolic-links for some more good info.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.