4

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
$

1 Answer 1

7

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".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .