Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

dir_1
    link_to_dir_3 ->

..

dir_2
    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

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.