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

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?


share|improve this question
up vote 1 down vote accepted

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

share|improve this answer
Perfect, thank you! – dotancohen Nov 21 '12 at 21:56

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.

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