Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

Thanks.

share|improve this question
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.