I'm in directory
~/a which is a symbolic link to
~/b/c. My prompt looks like:
But I hope to
~/a$ cd . ~/a$
It doesn't work. What's the right way?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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 user@host:~/tmp/b/c$
You can alias it to
From the bash manual:
The -P option says to use the physical directory structure instead of following symbolic links
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).
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).