Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

A large portion of my system depends on symbolic links, so this is a very serious problem. I do something like the following

cd
mkdir test
mkdir other
cd test
ln -s ../other/
# So ~/test contains a symlink to ~/other
cd other
dirname `pwd`
# So far so good; prints /home/user/test
ls ..
# Prints the contents of /home/user (???)
cd ..
# Now we're back in /home/user/test

So the parent of the current working directory and .. refer to two different locations in the context of ls (and also cp), but not cd.

I have observed this problem for all symlinks on my system, both existing and new (like the example above), and on multiple filesystems. The same thing happens in nautilus, which now shows the breadcrumbs of the physical path of any symlink I click, instead of the relative path. To my knowledge, I did not change anything that would cause an error like this, and booting an old kernel did not appear to fix the problem. I have seen many posts desiring this behavior, but none correcting it.

Any thoughts on this issue would be greatly appreciated. I am running Ubuntu Linux 12.10 3.11.0-18-generic.

share|improve this question

1 Answer 1

Your shell remembers when you cd into a directory via a symlink and uses that information when you cd ... If you use bash or zsh you can execute the command set -P in order to make cd behave the same as cp (i.e., make it ignore symbolic links so that in your example cd .. would take you to /home/user, not /home/user/test).

Refer to this Unix & Linux SE question for more information including a hack to make cp behave like cd instead of the opposite.

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.