Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 am trying to use symbolic links. I did some reading and found the following commands:

Creation -> ln -s {/path/to/file-name} {link-name}
Update -> ln -sfn {/path/to/file-name} {link-name}
Deletion -> rm {link-name}

Creations and deletions work fine. But updates do not work. After performing this command, the symlink becomes invalid.

I have read here and there that it is not possible to update/override a symlink. So there is contradictory information on the net. Who is right? If a symlink can be updated/overridden, how can I achieve this?


Here is my directory structure:


From ~/scripts/test/, when I perform:

ln -s /remote_loc/site1 test_link

a test_link is created, and I can ls -l it, but it seems broken (contrary to what I said above in my question).

How can I perform a multiple directory level link?

share|improve this question
I recommend to use unlink instead of rm. With unlink you never risk to lose any files in a source directory by accidentally using wrong switches. – Jpsy Jul 16 '14 at 9:04

Using -f with ln will overwrite any link that was already there, so as long as you have the correct permissions, it should work... It's always worked for me. What operating system are you using?

share|improve this answer
I have updated my question with more information on my issue. – JVerstry May 17 '12 at 12:56
I am under linux. – JVerstry May 17 '12 at 13:00
If you switch the ln parameters, as I am prone to do, will the -f switch destroy your existing files (link targets)? In either case, we have the -i parameter (which will prompt the user for overwrite) as well, if you want a bit of security. – palswim Jan 3 '15 at 6:10
@palswim This SO post implies it is safe because -f just calls unlink() and link() under the hood: I do wish I'd just remember the correct order, though! – Mike Branski Feb 9 '15 at 18:33
Does not work. Needs -n. See accepted answer. – Shawn Welch May 13 at 15:49
up vote 22 down vote accepted

Ok, I found where my error is: one should not put the first / in path.

In other words, the commands in my questions should be:

Creation -> ln -s {path/to/file-name} {link-name}
Update -> ln -sfn {path/to/file-name} {link-name}

instead of

Creation -> ln -s {/path/to/file-name} {link-name}
Update -> ln -sfn {/path/to/file-name} {link-name}

considering my case.

share|improve this answer
For some additional information on why that is, the differences are one is a relative path (without the leading /) and the other is an absolute path (with the leading /). If you're administrating a Linux system it is CRITICAL that you understand the differences. For instance the difference between rm -rf ./* and rm -rf /.* decides whether you keep your job or not :) – Safado May 17 '12 at 14:10
This doesnt answer the question 'how to update/overide a sym link' – Sirch May 17 '12 at 15:53
The ln -sfn {path/to/file-name} {link-name} line does. – JVerstry May 17 '12 at 17:27
What difference does the -n option make? – dokaspar May 13 at 8:56
$ touch test1 test2
$ ln -sf test2 test1
$ ls -l test[12]
lrwxrwxrwx 1 user01 user01 5 2012-05-17 14:41 test1 -> test2
-rw-r--r-- 1 user01 user01 0 2012-05-17 14:41 test2
share|improve this answer
When I perform tests with 1 level of directory, it works, but I am trying to use multi-level directories, and it does not work. I have updated my question. – JVerstry May 17 '12 at 12:57

Your Answer


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.