Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I'm in directory ~/a which is a symbolic link to ~/b/c. My prompt looks like:


But I hope to cd to ~/b/c.

~/a$ cd .

It doesn't work. What's the right way?

share|improve this question
up vote 3 down vote accepted

Here is a way of changing to the target of the given symbolic link:

cd -P .

Here is how it works

user@host:~/tmp$ ls 
@a b
user@host:~/tmp$ file a
a: symbolic link to `b/c'
user@host:~/tmp$ cd a
user@host:~/tmp/a$ cd .
user@host:~/tmp/a$ cd -P .a

You can alias it to

cdl='cd -P'

From the bash manual:

The -P option says to use the physical directory structure instead of following symbolic links

share|improve this answer
pretty cool. it's a strange that I haven't tried to consult the bash manual. – Lai Yu-Hsuan Sep 18 '12 at 10:51
Bash manual belongs to one of the most horrifying pieces of software documentation I know :-) – January Sep 18 '12 at 11:24

If you are simply trying to get to the other directory, then the solution is to enter it manually (otherwise the system will not follow the link back to its source).


cd ~/b/c

You can assign an alias for this using:

alias cdtobc="cd ~/b/c"

(The above is an example, and you can of course substitute values as needed).

share|improve this answer

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.