Ubuntu – Restore ‘cd ..’ functionality after following a symbolic link

command linedirectorysymbolic-link

If I create a symbolic link in the terminal with a command like

ln -s /path/to/some/directory symbolicLink

and then follow the link with

cd symbolicLink

the terminal appears to think that the cwd is ~/symbolicLink/ even though it is actually showing ~/path/to/some/directory/ (assuming that the link was made in ~, of course). What this means is that if I then type cd .. I am taken back to ~, because the terminal 'thinks' this is the parent of the cwd.

What would I need to change such that cd .. would instead take me to ~/path/to/some/, i.e. the real parent of ~/path/to/some/directory/?

Best Answer

See https://stackoverflow.com/questions/10456784/behavior-of-cd-bash-on-symbolic-links.

You can use 'cd -P' to go to the "real" parent directory. See the first comment on the top answer on how to make this the default behavior.

Related Question