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?



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

| improve this answer | |

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.

| improve this answer | |
  • 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 '12 at 21:55

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.