Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some trouble with symlinks and sshfs. I use the '-o follow_symlinks' option to follow symlinks on the server side, but whenever I edit a symlinked file on the client side with vim, a copy of it is made on the server side, i.e. it's no longer a symlink.

Set up a symlink on the server side:

me@machine1:~$ echo foo > test.txt
me@machine1:~$ mkdir test
me@machine1:~$ cd test
me@machine1:~/test$ ln -s ../test.txt test.txt
me@machine1:~/test$ ls -al test.txt
lrwxrwxrwx 1 me me 11 Jan  5 21:13 test.txt -> ../test.txt
me@machine1:~/test$ cat test.txt
me@machine1:~/test$ cat ../test.txt

So far so good. Now:

me@machine2:~$ mkdir test
me@machine2:~$ sshfs me@machine1:test test -o follow_symlinks
me@machine2:~$ cd test
me@machine2:~/test$ vim test.txt
[in vim, add a new line "bar" to the file]
me@machine2:~/test$ cat test.txt

Now observe what this does to the file on the server side:

me@machine1:~/test$ ls -al test.txt
-rw-r--r-- 1 me me 19 Jan  5 21:24 test.txt
me@machine1:~/test$ cat test.txt
me@machine1:~/test$ cat ../test.txt

As you can see, it made a copy and only edited the copy.

How can I get it to work so it actually follows the symlink when editing the file?

share|improve this question
is any other programm 'respecting the symlink' either? i mean, vim opens what is given by the filesystem... – akira Jan 6 '11 at 8:03
@akira: echo bar >> test.txt on the client machine preserves the symlink – HighCommander4 Jan 6 '11 at 18:37
Is this still an issue? From the question it looks like it's not copying the file, it's dropping the symlink and creating a new file. Would setting -o transform_symlinks be a better alternative? – vol7ron Mar 23 '14 at 21:28

You must log in to answer this question.

Browse other questions tagged .