user@DESKTOP-KK4CCE2:~$  mkdir -p ~/foo/bar/
user@DESKTOP-KK4CCE2:~$ touch ~/foo/bar/test.txt
user@DESKTOP-KK4CCE2:~$  mkdir ~/baz/
user@DESKTOP-KK4CCE2:~$ ln -s ~/foo/bar/ ~/baz/bar
user@DESKTOP-KK4CCE2:~$ cd ~/baz/bar/
user@DESKTOP-KK4CCE2:~/baz/bar$ cp test.txt ../
user@DESKTOP-KK4CCE2:~/baz/bar$ cd ..
user@DESKTOP-KK4CCE2:~/baz$ ls
user@DESKTOP-KK4CCE2:~/baz$ cd ~/foo
user@DESKTOP-KK4CCE2:~/foo$ ls
bar  test.txt

1 Answer 1


The gotcha is that when you cd ~/baz/bar you are now actually in ~/foo/bar. Your path only appears to be where you expect. So .. is the parent directory of ~/foo/bar, which is actually ~/foo.

  • Accessing the source through the link while in ~/baz, or giving the full path of the target from ~/baz/bar would have worked: cd ~/baz && cp bar/test.txt . or cd ~/baz/bar && cp test.txt ~/baz
    – Kusalananda
    Oct 6, 2022 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .