2

Is it possible to set up a symbolic link such that cd called on the link redirects to the linked path? Kind of like this:

$ ln /A/B /B/C
$ cd /A/B
$ pwd
/B/C
$
5

If you're using bash, zsh or any POSIX shell, then

cd -P
pwd -P

or to make it permanent.

  • in bash: set -P or set -o physical
  • in zsh: set -w or set -o chaselinks
  • in other POSIX shells: alias cd='cd -P'
  • in tcsh: set symlinks = chase

But the effect you're seeing is created by the shell, not by the link itself. So the answer to your actual question is "no".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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