Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 want to use symlinks extensively. However, if I move the target file, the symlink becomes broken (unlike on Windows). That's not acceptable to me, so I either need a solution or I won't be able to use symlinks the way I wish to.

Is there a solution that will work with Dolphin file manager?

A command line solution is described on commandlinefu. In summary, it is something like one of these:

lmv(){for a in ${@:1:$(expr $#-1)};do [ -e "$a" -a -e "${@:$#:1}" ] && mv "$a";"${@:$#:1}" && ln -s "${@:$#:1}"/"$(basename "$a")";"$(dirname "$a")";done}

lmv(){for a in ${@:1:$(expr $#-1)};do [ -e "$a" -a -e "${@:$#}" ]   && mv "$a";"${@:$#}"   && ln -s "${@:$#}"/"$(basename "$a")";"$(dirname "$a")";done}

But about half the time I'm using a file manager (Dolphin), so I need a complete solution to this problem. Is a solution available for a GUI file manager?

EDIT: The context of this question is that I'm searching for an alternative to hardlinks. I previously asked this question about the pitfalls of hardlinks.

share|improve this question
"unlike on Windows"..... except for those new applications shortcuts in Vista/7 I'm not sure what you mean by that. Maybe what you want are Hardlinks? Hardlinks will not work for directories however. – Huckle Mar 30 '12 at 2:02
This was my question about hardlinks:… I may end up using hardlinks, but I'm looking at alternatives. Smart symlinks (if they are possible) would be one alternative. My other alternative is probably to make all the hardlinked files read-only by default and switch my text editor to something that respects that permission better. – MountainX Mar 30 '12 at 3:21
Regarding Windows, I haven't used it in about 6-7 years, so I presume I'm wrong about how shortcuts work on it. But I read someone say that the shortcuts follow the files as they are moved (so the shortcuts don't break). That's what I'd like to achieve, if possible. – MountainX Mar 30 '12 at 3:22
When A is the shortcut and B is the actual file, moving A would mean it still worked as long as it's reference to B was still valid, but if you move B, then A's reference isn't valid. Are you sure they didn't mean moving the shortcut and not the file it pointed to, this seems much more common and likely scenario IMO, and in that sense symlinks will work fine I think. – Jeff Welling Mar 30 '12 at 4:02
@Jeff - what I read was that moving file B somehow automatically updates the shortcut A. I don't know if that's actually true for Windows, but it is the result I'm trying to achieve on Linux. It can be done on the command line, as per the code in my question. But I want to see if Dolphin can be made to do it as well. – MountainX Mar 30 '12 at 4:11
up vote 2 down vote accepted

As suggested by Huckle, it sound's like what you want are hardlinks, though as he notes that won't work for directories.

Sidenote, If there is a reason that hardlinks won't work in for you, adding it to your question may help get answers that are of more help to you.

share|improve this answer
Thanks. I edited my question. I'm looking for an alternative to hardlinks. I'm thinking of them as "smart symlinks" (somewhat like smart pointers in C++ maybe). – MountainX Mar 30 '12 at 3:27

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.