1

Let's say (hypothetically) that I wanted to make a symlink to my Documents folder on my Desktop. I would do this:

cd ~/Desktop
ln -s ~/Documents

which will make a symlink called Documents on my Desktop.

However, when I do this (note the trailing slash after ~/Documents:

cd ~/Desktop
ln -s ~/Documents/

I get:

ln: ./: File exists

Howcome? Why does the trailing slash matter in this case, and what does a trailing slash mean in general?

user1516425
  • 1,531
  • 2
  • 15
  • 21

1 Answers1

2

As noted in the comments, the trailing slash is application-dependent. On my system (CentOS 5), both worked fine.

In this case, I'd say that ln is interpreting ~/Documents/ as a path, and using a default filename of . to refer to the current directory, for an effective combined path of ~/Documents/.. Since you're not specifying the name of the destination link, it's picking the one that matches the 'sepecified' filename, ., which already exists.

I get a similar error to yours when I specify ~/Documents/. explicitly.

You can solve this by specifying the name of the link to create explicitly. ln -s ~/Documents/ Documents should work for you.

David Yaw
  • 27,383
  • 4
  • 60
  • 93