Super User is a question and answer site for computer enthusiasts and power users. 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

How can i cd into a symbolically linked directory but, when moving from there, doing it relatively to the real directory?

For example

    link_to_dir_3 ->



If I do cd link_to_dir_3 and then cd .. I wanto tp go to dir_2 and not dir_1. Thanks

share|improve this question
cd `pwd -P`
cd ..

The first cd will take you from dir_1/link_to_dir_3 to dir_2/dir_3.

share|improve this answer

Use readlink:

cd $(readlink -n link)
share|improve this answer

You must log in to answer this question.

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