In each users' directory there exists a symbolic link to /var/www/website/public_html/. However, whenever a user cds into the link, he sees the path as /home/username/public_html/. Is there any way to link to a directory however when the user changes into the directory, the command pwd will show the canonical or real path to the directory?


2 Answers 2


That's a feature of modern shells (the Bourne shell and original csh (and probably the original Almquist shell as well) were not affected). Use cd -P to work around it:

cd -P public_html

You can make that the default with

alias cd='cd -P'

POSIXly, or as Chris said:

set -o physical

in bash or zsh or

setopt chaselinks

in zsh or

set symlinks = chase

in tcsh.

  • Thank you Stephane. (Is that pronounced stef-an or stef-an-e?) I think that I'm familiar with this type of feature!
    – dotancohen
    Nov 21, 2012 at 21:55

In addition to what Stephane said, you can also use set -o physical to do this by default in bash.


You must log in to answer this question.

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