I have built my app for different architectures and would like to create a "dynamic symlink" which takes me to the right version based on a variable.

If the machine I am currently logged in to, is x86, then the symlink should take me to that build.

A mocked example of what I want to do:

$ uname -i

$ ls -ltr 
lrwxr-xr-x  1 dogbane gg     4 Feb 16 15:40 mylink -> @sys/
drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 x86_64/
drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 i386/

$ cd mylink

$ pwd -P

Is this possible?

I know I can use cd $(uname -i), but want something simpler.

  • Are you familiar with OpenAFS? Because it uses @sys in exactly that way, even using '@sys'. If so, are you looking for an alternative to OpenAFS?
    – jsbillings
    Feb 16, 2011 at 16:04
  • @jsbilling I'd like to know if this is possible on a standard filesystem, without AFS. I used to work on AFS a long time ago and could do this, hence why I asked.
    – dogbane
    Feb 16, 2011 at 16:28
  • I figured as much. I know of no other filesystem that has 'magic' symlinks other than NetBSD's vfs.generic.magiclinks setting. (daemon-systems.org/man/symlink.7.html)
    – jsbillings
    Feb 16, 2011 at 17:34
  • There are such environments for e.g. Ruby and Perl, so that you can choose which version to use when you're testing things. You might find some inspiration at rvm.io/rubies .
    – Jenny D
    Apr 10, 2014 at 10:29

5 Answers 5


This feature is supported by DragonFly BSD, where it is called variant symlinks. See man varsym and man ln for details.


Symbolic links are static: the filesystem just stores a string, and accesses to the symbolic link are redirected to the file whose name (relative to the location of the symlink) is that string.

It would be simple to write a FUSE filesystem exposing such dynamic symlinks, but I don't know of an existing one.


I assume this is binaries, so I would do it with a PATH variable rater than symlink.


If you are using a tool like cfengine or puppet. A symlink to the appropriate directory can be created based on the system architecture.


If you just want a simpler syntax to type than:

cd $(uname -i)

You could put it in a variable like:

 s=`uname -i` 

in your login script, so you can just do

 cd $s

When you want to cd


symlink is essentially a file with special flag which contains some path, and this path interpreted as is, so you can not make one symlink to point to other locations in that way. But you still may write script that will run apropriate build.

You must log in to answer this question.

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